Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/eventfd: open code io_eventfd_grab()

io_eventfd_grab() doesn't help wit understanding the path, it'll be
simpler to keep the helper open coded.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/5cb53ce3876c2819db9e8055cf41dca4398521db.1745493845.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
f6da4fee da01f60f

+10 -30
+10 -30
io_uring/eventfd.c
··· 65 65 66 66 /* 67 67 * Trigger if eventfd_async isn't set, or if it's set and the caller is 68 - * an async worker. If ev_fd isn't valid, obviously return false. 68 + * an async worker. 69 69 */ 70 70 static bool io_eventfd_trigger(struct io_ev_fd *ev_fd) 71 71 { 72 - if (ev_fd) 73 - return !ev_fd->eventfd_async || io_wq_current_is_worker(); 74 - return false; 75 - } 76 - 77 - /* 78 - * On success, returns with an ev_fd reference grabbed and the RCU read 79 - * lock held. 80 - */ 81 - static struct io_ev_fd *io_eventfd_grab(struct io_ring_ctx *ctx) 82 - { 83 - struct io_ev_fd *ev_fd; 84 - 85 - /* 86 - * rcu_dereference ctx->io_ev_fd once and use it for both for checking 87 - * and eventfd_signal 88 - */ 89 - ev_fd = rcu_dereference(ctx->io_ev_fd); 90 - 91 - /* 92 - * Check again if ev_fd exists in case an io_eventfd_unregister call 93 - * completed between the NULL check of ctx->io_ev_fd at the start of 94 - * the function and rcu_read_lock. 95 - */ 96 - if (io_eventfd_trigger(ev_fd) && refcount_inc_not_zero(&ev_fd->refs)) 97 - return ev_fd; 98 - 99 - return NULL; 72 + return !ev_fd->eventfd_async || io_wq_current_is_worker(); 100 73 } 101 74 102 75 void io_eventfd_signal(struct io_ring_ctx *ctx, bool cqe_event) ··· 81 108 return; 82 109 83 110 guard(rcu)(); 84 - ev_fd = io_eventfd_grab(ctx); 111 + ev_fd = rcu_dereference(ctx->io_ev_fd); 112 + /* 113 + * Check again if ev_fd exists in case an io_eventfd_unregister call 114 + * completed between the NULL check of ctx->io_ev_fd at the start of 115 + * the function and rcu_read_lock. 116 + */ 85 117 if (!ev_fd) 118 + return; 119 + if (!io_eventfd_trigger(ev_fd) || !refcount_inc_not_zero(&ev_fd->refs)) 86 120 return; 87 121 88 122 if (cqe_event) {