io_eventfd_put(ev_fd);
}
-static void io_eventfd_release(struct io_ev_fd *ev_fd, bool put_ref)
-{
- if (put_ref)
- io_eventfd_put(ev_fd);
- rcu_read_unlock();
-}
-
/*
* Returns true if the caller should put the ev_fd reference, false if not.
*/
{
struct io_ev_fd *ev_fd;
- if (READ_ONCE(ctx->rings->cq_flags) & IORING_CQ_EVENTFD_DISABLED)
- return NULL;
-
- rcu_read_lock();
-
/*
* rcu_dereference ctx->io_ev_fd once and use it for both for checking
* and eventfd_signal
if (io_eventfd_trigger(ev_fd) && refcount_inc_not_zero(&ev_fd->refs))
return ev_fd;
- rcu_read_unlock();
return NULL;
}
void io_eventfd_signal(struct io_ring_ctx *ctx, bool cqe_event)
{
- bool skip = false, put_ref = true;
+ bool skip = false;
struct io_ev_fd *ev_fd;
+ if (READ_ONCE(ctx->rings->cq_flags) & IORING_CQ_EVENTFD_DISABLED)
+ return;
+
+ guard(rcu)();
ev_fd = io_eventfd_grab(ctx);
if (!ev_fd)
return;
spin_unlock(&ctx->completion_lock);
}
- if (!skip)
- put_ref = __io_eventfd_signal(ev_fd);
- io_eventfd_release(ev_fd, put_ref);
+ if (skip || __io_eventfd_signal(ev_fd))
+ io_eventfd_put(ev_fd);
}
int io_eventfd_register(struct io_ring_ctx *ctx, void __user *arg,