mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
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>
This commit is contained in:
parent
da01f60f8a
commit
f6da4fee69
1 changed files with 10 additions and 30 deletions
|
@ -65,38 +65,11 @@ static bool __io_eventfd_signal(struct io_ev_fd *ev_fd)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Trigger if eventfd_async isn't set, or if it's set and the caller is
|
* 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.
|
* an async worker.
|
||||||
*/
|
*/
|
||||||
static bool io_eventfd_trigger(struct io_ev_fd *ev_fd)
|
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 !ev_fd->eventfd_async || io_wq_current_is_worker();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* On success, returns with an ev_fd reference grabbed and the RCU read
|
|
||||||
* lock held.
|
|
||||||
*/
|
|
||||||
static struct io_ev_fd *io_eventfd_grab(struct io_ring_ctx *ctx)
|
|
||||||
{
|
|
||||||
struct io_ev_fd *ev_fd;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* rcu_dereference ctx->io_ev_fd once and use it for both for checking
|
|
||||||
* and eventfd_signal
|
|
||||||
*/
|
|
||||||
ev_fd = rcu_dereference(ctx->io_ev_fd);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check again if ev_fd exists in case an io_eventfd_unregister call
|
|
||||||
* completed between the NULL check of ctx->io_ev_fd at the start of
|
|
||||||
* the function and rcu_read_lock.
|
|
||||||
*/
|
|
||||||
if (io_eventfd_trigger(ev_fd) && refcount_inc_not_zero(&ev_fd->refs))
|
|
||||||
return ev_fd;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_eventfd_signal(struct io_ring_ctx *ctx, bool cqe_event)
|
void io_eventfd_signal(struct io_ring_ctx *ctx, bool cqe_event)
|
||||||
|
@ -108,9 +81,16 @@ void io_eventfd_signal(struct io_ring_ctx *ctx, bool cqe_event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
guard(rcu)();
|
guard(rcu)();
|
||||||
ev_fd = io_eventfd_grab(ctx);
|
ev_fd = rcu_dereference(ctx->io_ev_fd);
|
||||||
|
/*
|
||||||
|
* Check again if ev_fd exists in case an io_eventfd_unregister call
|
||||||
|
* completed between the NULL check of ctx->io_ev_fd at the start of
|
||||||
|
* the function and rcu_read_lock.
|
||||||
|
*/
|
||||||
if (!ev_fd)
|
if (!ev_fd)
|
||||||
return;
|
return;
|
||||||
|
if (!io_eventfd_trigger(ev_fd) || !refcount_inc_not_zero(&ev_fd->refs))
|
||||||
|
return;
|
||||||
|
|
||||||
if (cqe_event) {
|
if (cqe_event) {
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue