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.
Unified · Split
| @@ -1153,6 +1153,8 @@ static inline bool io_should_trigger_evfd(struct io_ring_ctx *ctx) · 1152 unmodified lines | ||
| 1153 | 1153 | { |
| 1154 | 1154 | if (!ctx->cq_ev_fd) |
| 1155 | 1155 | return false; |
| 1156 | + if (READ_ONCE(ctx->rings->cq_flags) & IORING_CQ_EVENTFD_DISABLED) | |
| 1157 | + return false; | |
| 1156 | 1158 | if (!ctx->eventfd_async) |
| 1157 | 1159 | return true; |
| 1158 | 1160 | return io_wq_current_is_worker(); |
| @@ -209,6 +209,13 @@ struct io_cqring_offsets { · 208 unmodified lines | ||
| 209 | 209 | __u64 resv2; |
| 210 | 210 | }; |
| 211 | 211 | |
| 212 | +/* | |
| 213 | + * cq_ring->flags | |
| 214 | + */ | |
| 215 | + | |
| 216 | +/* disable eventfd notifications */ | |
| 217 | +#define IORING_CQ_EVENTFD_DISABLED (1U << 0) | |
| 218 | + | |
| 212 | 219 | /* |
| 213 | 220 | * io_uring_enter(2) flags |
| 214 | 221 | */ |