From: Josh Law <objecting@objecting.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org,
Josh Law <objecting@objecting.org>
Subject: [PATCH] io_uring: flush deferred completions in io_req_post_cqe32()
Date: Thu, 19 Mar 2026 20:49:19 +0000 [thread overview]
Message-ID: <20260319204919.13403-1-objecting@objecting.org> (raw)
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
reply other threads:[~2026-03-19 20:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260319204919.13403-1-objecting@objecting.org \
--to=objecting@objecting.org \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.