diff options
authorPavel Begunkov <>2021-12-05 14:37:59 +0000
committerJens Axboe <>2021-12-05 08:56:24 -0700
commit83a13a4181b0e874d1f196e11b953c3c9f009f68 (patch)
parentd1fd1c201d750711e17377acb4914d3ea29a608c (diff)
io_uring: tweak iopoll CQE_SKIP event counting
When iopolling the userspace specifies the minimum number of "events" it expects. Previously, we had one CQE per request, so the definition of an "event" was unequivocal, but that's not more the case anymore with REQ_F_CQE_SKIP. Currently it counts the number of completed requests, replace it with the number of posted CQEs. This allows users of the "one CQE per link" scheme to wait for all N links in a single syscall, which is not possible without the patch and requires extra context switches. Signed-off-by: Pavel Begunkov <> Link: Signed-off-by: Jens Axboe <>
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 64add8260abb..ea7a0daa0b3b 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2538,10 +2538,10 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin)
/* order with io_complete_rw_iopoll(), e.g. ->result updates */
if (!smp_load_acquire(&req->iopoll_completed))
+ if (unlikely(req->flags & REQ_F_CQE_SKIP))
+ continue;
- if (!(req->flags & REQ_F_CQE_SKIP))
- __io_fill_cqe(ctx, req->user_data, req->result,
- io_put_kbuf(req));
+ __io_fill_cqe(ctx, req->user_data, req->result, io_put_kbuf(req));