summaryrefslogtreecommitdiff
path: root/io_uring/net.h
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-03-17 00:33:53 +0300
committerJens Axboe <axboe@kernel.dk>2024-04-15 17:10:25 +0300
commit75191341785eef51f87ff54b0ed9dfbd5a72e7c2 (patch)
tree33947a04775e0046da23bb4a0929f4adb6ca4c92 /io_uring/net.h
parent9f8539fe299c250af42325eccff66e8b8d1f15da (diff)
downloadlinux-75191341785eef51f87ff54b0ed9dfbd5a72e7c2.tar.xz
io_uring/net: add iovec recycling
Right now the io_async_msghdr is recycled to avoid the overhead of allocating+freeing it for every request. But the iovec is not included, hence that will be allocated and freed for each transfer regardless. This commit enables recyling of the iovec between io_async_msghdr recycles. This avoids alloc+free for each one if an iovec is used, and on top of that, it extends the cache hot nature of msg to the iovec as well. Also enables KASAN for the iovec entries, so that reuse can be detected even while they are in the cache. The io_async_msghdr also shrinks from 376 -> 288 bytes, an 88 byte saving (or ~23% smaller), as the fast_iovec entry is dropped from 8 entries to a single entry. There's no point keeping a big fast iovec entry, if iovecs aren't being allocated and freed continually. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/net.h')
-rw-r--r--io_uring/net.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/io_uring/net.h b/io_uring/net.h
index f99ebb9dc0bb..0aef1c992aee 100644
--- a/io_uring/net.h
+++ b/io_uring/net.h
@@ -8,17 +8,18 @@
struct io_async_msghdr {
#if defined(CONFIG_NET)
union {
- struct iovec fast_iov[UIO_FASTIOV];
+ struct iovec fast_iov;
struct {
- struct iovec fast_iov_one;
- __kernel_size_t controllen;
- int namelen;
- __kernel_size_t payloadlen;
+ struct io_cache_entry cache;
+ /* entry size of ->free_iov, if valid */
+ int free_iov_nr;
};
- struct io_cache_entry cache;
};
/* points to an allocated iov, if NULL we use fast_iov instead */
struct iovec *free_iov;
+ __kernel_size_t controllen;
+ __kernel_size_t payloadlen;
+ int namelen;
struct sockaddr __user *uaddr;
struct msghdr msg;
struct sockaddr_storage addr;