io_uring: add IORING_CQ_EVENTFD_DISABLED to the CQ ring flags
authorStefano Garzarella <sgarzare@redhat.com>
Fri, 15 May 2020 16:38:05 +0000 (18:38 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 15 May 2020 18:16:59 +0000 (12:16 -0600)
This new flag should be set/clear from the application to
disable/enable 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 IORING_CQ_EVENTFD_DISABLED is not set during the
initialization.

It will be up to the application to set the flag after initialization
if no notifications are required at the beginning.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c
include/uapi/linux/io_uring.h

index 02250693a406ce18cef0b46f1e34225c5a287f32..f800b0b4498f11ed61c9d0e8d0f74321ac8015cd 100644 (file)
@@ -1153,6 +1153,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_EVENTFD_DISABLED)
+               return false;
        if (!ctx->eventfd_async)
                return true;
        return io_wq_current_is_worker();
index 602bb0ece6075175e3beba5db91edf7fd58aabb1..8c5775df08b87139be2b26973f949853f00e1400 100644 (file)
@@ -209,6 +209,13 @@ struct io_cqring_offsets {
        __u64 resv2;
 };
 
+/*
+ * cq_ring->flags
+ */
+
+/* disable eventfd notifications */
+#define IORING_CQ_EVENTFD_DISABLED     (1U << 0)
+
 /*
  * io_uring_enter(2) flags
  */