summaryrefslogtreecommitdiffstats
path: root/io_uring/napi.h
diff options
context:
space:
mode:
authorOlivier Langlois <olivier@trillion01.com>2024-10-13 20:28:50 +0200
committerJens Axboe <axboe@kernel.dk>2024-11-06 21:55:38 +0100
commita5e26f49fef9485bc4ae24666d984a6de11e058c (patch)
tree878bfe97fd47d93ef7e38066791cb63434b65c4d /io_uring/napi.h
parentio_uring/napi: fix io_napi_entry RCU accesses (diff)
downloadlinux-a5e26f49fef9485bc4ae24666d984a6de11e058c.tar.xz
linux-a5e26f49fef9485bc4ae24666d984a6de11e058c.zip
io_uring/napi: improve __io_napi_add
1. move the sock->sk pointer validity test outside the function to avoid the function call overhead and to make the function more more reusable 2. change its name to __io_napi_add_id to be more precise about it is doing 3. return an error code to report errors Signed-off-by: Olivier Langlois <olivier@trillion01.com> Link: https://lore.kernel.org/r/d637fa3b437d753c0f4e44ff6a7b5bf2c2611270.1728828877.git.olivier@trillion01.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/napi.h')
-rw-r--r--io_uring/napi.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/io_uring/napi.h b/io_uring/napi.h
index fd275ef0456d..4ae622f37b30 100644
--- a/io_uring/napi.h
+++ b/io_uring/napi.h
@@ -15,7 +15,7 @@ void io_napi_free(struct io_ring_ctx *ctx);
int io_register_napi(struct io_ring_ctx *ctx, void __user *arg);
int io_unregister_napi(struct io_ring_ctx *ctx, void __user *arg);
-void __io_napi_add(struct io_ring_ctx *ctx, struct socket *sock);
+int __io_napi_add_id(struct io_ring_ctx *ctx, unsigned int napi_id);
void __io_napi_busy_loop(struct io_ring_ctx *ctx, struct io_wait_queue *iowq);
int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx);
@@ -48,8 +48,8 @@ static inline void io_napi_add(struct io_kiocb *req)
return;
sock = sock_from_file(req->file);
- if (sock)
- __io_napi_add(ctx, sock);
+ if (sock && sock->sk)
+ __io_napi_add_id(ctx, READ_ONCE(sock->sk->sk_napi_id));
}
#else