@@ -1152,6 +1152,8 @@ static inline bool io_should_trigger_evfd(struct io_ring_ctx *ctx)
{
if (!ctx->cq_ev_fd)
return false;
+ if (!(READ_ONCE(ctx->rings->cq_flags) & IORING_CQ_NEED_WAKEUP))
+ return false;
if (!ctx->eventfd_async)
return true;
return io_wq_current_is_worker();
@@ -7684,6 +7686,11 @@ static int io_allocate_scq_urings(struct io_ring_ctx *ctx,
rings->cq_ring_mask = p->cq_entries - 1;
rings->sq_ring_entries = p->sq_entries;
rings->cq_ring_entries = p->cq_entries;
+ /*
+ * For backward compatibility we start with eventfd notification
+ * enabled.
+ */
+ rings->cq_flags |= IORING_CQ_NEED_WAKEUP;
ctx->sq_mask = rings->sq_ring_mask;
ctx->cq_mask = rings->cq_ring_mask;
ctx->sq_entries = rings->sq_ring_entries;
@@ -209,6 +209,11 @@ struct io_cqring_offsets {
__u64 resv2;
};
+/*
+ * cq_ring->flags
+ */
+#define IORING_CQ_NEED_WAKEUP (1U << 0) /* needs wakeup through eventfd */
+
/*
* io_uring_enter(2) flags
*/
This new flag should be set/clear from the application to enable/disable eventfd notifications when a request is completed and queued to the CQ ring. Before this patch, notifications were always sent if an eventfd is registered, so to remain backwards compatible we enable them during initialization. It will be up to the application to disable them after initialization if no notifications are required at the beginning. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> --- fs/io_uring.c | 7 +++++++ include/uapi/linux/io_uring.h | 5 +++++ 2 files changed, 12 insertions(+)