* [PATCH] io_uring: flush deferred completions in io_req_post_cqe32()
@ 2026-03-19 20:49 Josh Law
0 siblings, 0 replies; only message in thread
From: Josh Law @ 2026-03-19 20:49 UTC (permalink / raw)
To: Jens Axboe; +Cc: io-uring, linux-kernel, Josh Law
io_req_post_cqe32() is missing the deferred completion flush that its
sibling io_req_post_cqe() has. Without flushing pending deferred
completions before posting a 32-byte CQE, multishot CQEs can be
delivered to userspace out of order.
Add the same flush check that io_req_post_cqe() performs.
Signed-off-by: Josh Law <objecting@objecting.org>
---
io_uring/io_uring.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 9a37035e76c0..43d2f2b0830d 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -881,6 +881,14 @@ bool io_req_post_cqe32(struct io_kiocb *req, struct io_uring_cqe cqe[2])
struct io_ring_ctx *ctx = req->ctx;
bool posted;
+ /*
+ * If multishot has already posted deferred completions, ensure that
+ * those are flushed first before posting this one. If not, CQEs
+ * could get reordered.
+ */
+ if (!wq_list_empty(&ctx->submit_state.compl_reqs))
+ __io_submit_flush_completions(ctx);
+
lockdep_assert(!io_wq_current_is_worker());
lockdep_assert_held(&ctx->uring_lock);
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-19 20:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 20:49 [PATCH] io_uring: flush deferred completions in io_req_post_cqe32() Josh Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox