summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-09-21 10:59:50 +0300
committerJens Axboe <axboe@kernel.dk>2024-10-29 22:43:26 +0300
commit3ca5a356041438534ecbb74159df91736238c6b1 (patch)
tree1299e09b424282700ed2fd19f928821a39d8684d
parent60c5f15800f21883615689e2423217a9c8a1b502 (diff)
downloadlinux-3ca5a356041438534ecbb74159df91736238c6b1.tar.xz
io_uring/eventfd: move trigger check into a helper
It's a bit hard to read what guards the triggering, move it into a helper and add a comment explaining it too. This additionally moves the ev_fd == NULL check in there as well. Link: https://lore.kernel.org/r/20240921080307.185186-5-axboe@kernel.dk Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--io_uring/eventfd.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/io_uring/eventfd.c b/io_uring/eventfd.c
index 58e76f4d1e00..0946d3da88d3 100644
--- a/io_uring/eventfd.c
+++ b/io_uring/eventfd.c
@@ -63,6 +63,17 @@ static bool __io_eventfd_signal(struct io_ev_fd *ev_fd)
return true;
}
+/*
+ * Trigger if eventfd_async isn't set, or if it's set and the caller is
+ * an async worker. If ev_fd isn't valid, obviously return false.
+ */
+static bool io_eventfd_trigger(struct io_ev_fd *ev_fd)
+{
+ if (ev_fd)
+ return !ev_fd->eventfd_async || io_wq_current_is_worker();
+ return false;
+}
+
void io_eventfd_signal(struct io_ring_ctx *ctx)
{
struct io_ev_fd *ev_fd = NULL;
@@ -83,9 +94,7 @@ void io_eventfd_signal(struct io_ring_ctx *ctx)
* completed between the NULL check of ctx->io_ev_fd at the start of
* the function and rcu_read_lock.
*/
- if (unlikely(!ev_fd))
- return;
- if (ev_fd->eventfd_async && !io_wq_current_is_worker())
+ if (!io_eventfd_trigger(ev_fd))
return;
if (!refcount_inc_not_zero(&ev_fd->refs))
return;