No description
Find a file
Michael Kelley 7296f2301a swiotlb: reduce swiotlb pool lookups
With CONFIG_SWIOTLB_DYNAMIC enabled, each round-trip map/unmap pair
in the swiotlb results in 6 calls to swiotlb_find_pool(). In multiple
places, the pool is found and used in one function, and then must
be found again in the next function that is called because only the
tlb_addr is passed as an argument. These are the six call sites:

dma_direct_map_page:
 1. swiotlb_map -> swiotlb_tbl_map_single -> swiotlb_bounce

dma_direct_unmap_page:
 2. dma_direct_sync_single_for_cpu -> is_swiotlb_buffer
 3. dma_direct_sync_single_for_cpu -> swiotlb_sync_single_for_cpu ->
	swiotlb_bounce
 4. is_swiotlb_buffer
 5. swiotlb_tbl_unmap_single -> swiotlb_del_transient
 6. swiotlb_tbl_unmap_single -> swiotlb_release_slots

Reduce the number of calls by finding the pool at a higher level, and
passing it as an argument instead of searching again. A key change is
for is_swiotlb_buffer() to return a pool pointer instead of a boolean,
and then pass this pool pointer to subsequent swiotlb functions.

There are 9 occurrences of is_swiotlb_buffer() used to test if a buffer
is a swiotlb buffer before calling a swiotlb function. To reduce code
duplication in getting the pool pointer and passing it as an argument,
introduce inline wrappers for this pattern. The generated code is
essentially unchanged.

Since is_swiotlb_buffer() no longer returns a boolean, rename some
functions to reflect the change:

 * swiotlb_find_pool() becomes __swiotlb_find_pool()
 * is_swiotlb_buffer() becomes swiotlb_find_pool()
 * is_xen_swiotlb_buffer() becomes xen_swiotlb_find_pool()

With these changes, a round-trip map/unmap pair requires only 2 pool
lookups (listed using the new names and wrappers):

dma_direct_unmap_page:
 1. dma_direct_sync_single_for_cpu -> swiotlb_find_pool
 2. swiotlb_tbl_unmap_single -> swiotlb_find_pool

These changes come from noticing the inefficiencies in a code review,
not from performance measurements. With CONFIG_SWIOTLB_DYNAMIC,
__swiotlb_find_pool() is not trivial, and it uses an RCU read lock,
so avoiding the redundant calls helps performance in a hot path.
When CONFIG_SWIOTLB_DYNAMIC is *not* set, the code size reduction
is minimal and the perf benefits are likely negligible, but no
harm is done.

No functional change is intended.

Signed-off-by: Michael Kelley <mhklinux@outlook.com>
Reviewed-by: Petr Tesarik <petr@tesarici.cz>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2024-07-10 07:59:03 +02:00
arch powerpc fixes for 6.10 #4 2024-07-06 18:31:24 -07:00
block block: unmap and free user mapped integrity via submitter 2024-06-12 11:00:50 -06:00
certs
crypto
Documentation RISC-V Fixes for 6.10-rc7 2024-07-05 12:22:51 -07:00
drivers swiotlb: reduce swiotlb pool lookups 2024-07-10 07:59:03 +02:00
fs fix for smb3 readahead performance regression 2024-07-06 16:16:58 -07:00
include swiotlb: reduce swiotlb pool lookups 2024-07-10 07:59:03 +02:00
init gcc: disable '-Warray-bounds' for gcc-9 2024-06-15 10:43:04 -07:00
io_uring io_uring/net: don't clear msg_inq before io_recv_buf_select() needs it 2024-07-02 09:42:10 -06:00
ipc
kernel swiotlb: reduce swiotlb pool lookups 2024-07-10 07:59:03 +02:00
lib hardening fixes for v6.10-rc6 2024-06-28 16:11:02 -07:00
LICENSES
mm mm: avoid overflows in dirty throttling logic 2024-07-03 12:29:24 -07:00
net Including fixes from bluetooth, wireless and netfilter. 2024-07-04 10:11:12 -07:00
rust rust: avoid unused import warning in rusttest 2024-06-11 23:33:28 +02:00
samples
scripts kbuild: scripts/gdb: bring the "abspath" back 2024-06-27 04:20:32 +09:00
security integrity-v6.10-fix 2024-07-05 16:21:54 -07:00
sound ASoC: Fixes for v6.10 2024-06-26 22:02:55 +02:00
tools powerpc fixes for 6.10 #4 2024-07-06 18:31:24 -07:00
usr
virt KVM fixes for 6.10 2024-06-21 08:03:55 -04:00
.clang-format
.cocciconfig
.editorconfig .editorconfig: remove trim_trailing_whitespace option 2024-06-13 16:47:52 +02:00
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap bpf-for-netdev 2024-06-14 17:57:10 -07:00
.rustfmt.toml
COPYING
CREDITS pci-v6.10-fixes-2 2024-07-05 12:33:00 -07:00
Kbuild
Kconfig
MAINTAINERS pci-v6.10-fixes-2 2024-07-05 12:33:00 -07:00
Makefile Linux 6.10-rc7 2024-07-07 14:23:46 -07:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the reStructuredText markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.