* FAILED: patch "[PATCH] io_uring: ensure deferred completions are flushed for" failed to apply to 6.1-stable tree
@ 2025-05-12 10:01 gregkh
2025-05-12 13:07 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2025-05-12 10:01 UTC (permalink / raw)
To: axboe, christian.mazakas, norman_maurer; +Cc: stable
The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 687b2bae0efff9b25e071737d6af5004e6e35af5
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025051212-antirust-outshoot-07f7@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 687b2bae0efff9b25e071737d6af5004e6e35af5 Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@kernel.dk>
Date: Wed, 7 May 2025 07:34:24 -0600
Subject: [PATCH] io_uring: ensure deferred completions are flushed for
multishot
Multishot normally uses io_req_post_cqe() to post completions, but when
stopping it, it may finish up with a deferred completion. This is fine,
except if another multishot event triggers before the deferred completions
get flushed. If this occurs, then CQEs may get reordered in the CQ ring,
as new multishot completions get posted before the deferred ones are
flushed. This can cause confusion on the application side, if strict
ordering is required for the use case.
When multishot posting via io_req_post_cqe(), flush any pending deferred
completions first, if any.
Cc: stable@vger.kernel.org # 6.1+
Reported-by: Norman Maurer <norman_maurer@apple.com>
Reported-by: Christian Mazakas <christian.mazakas@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 769814d71153..541e65a1eebf 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -848,6 +848,14 @@ bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags)
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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring: ensure deferred completions are flushed for" failed to apply to 6.1-stable tree
2025-05-12 10:01 FAILED: patch "[PATCH] io_uring: ensure deferred completions are flushed for" failed to apply to 6.1-stable tree gregkh
@ 2025-05-12 13:07 ` Jens Axboe
2025-05-12 13:54 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2025-05-12 13:07 UTC (permalink / raw)
To: gregkh, christian.mazakas, norman_maurer; +Cc: stable
[-- Attachment #1: Type: text/plain, Size: 348 bytes --]
On 5/12/25 4:01 AM, gregkh@linuxfoundation.org wrote:
>
> The patch below does not apply to the 6.1-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
Here's a tested 6.1-stable backport.
--
Jens Axboe
[-- Attachment #2: 0002-io_uring-ensure-deferred-completions-are-posted-for-.patch --]
[-- Type: text/x-patch, Size: 1624 bytes --]
From d714dbdfce858bc320a0e9f983f72652988ff11b Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@kernel.dk>
Date: Wed, 7 May 2025 08:07:09 -0600
Subject: [PATCH 2/2] io_uring: ensure deferred completions are posted for
multishot
Commit 687b2bae0efff9b25e071737d6af5004e6e35af5 upstream.
Multishot normally uses io_req_post_cqe() to post completions, but when
stopping it, it may finish up with a deferred completion. This is fine,
except if another multishot event triggers before the deferred completions
get flushed. If this occurs, then CQEs may get reordered in the CQ ring,
and cause confusion on the application side.
When multishot posting via io_req_post_cqe(), flush any pending deferred
completions first, if any.
Cc: stable@vger.kernel.org # 6.1+
Reported-by: Norman Maurer <norman_maurer@apple.com>
Reported-by: Christian Mazakas <christian.mazakas@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
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 488793b119d0..f39d66589180 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -819,6 +819,14 @@ bool io_post_aux_cqe(struct io_ring_ctx *ctx,
{
bool filled;
+ /*
+ * 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);
+
io_cq_lock(ctx);
filled = io_fill_cqe_aux(ctx, user_data, res, cflags, allow_overflow);
io_cq_unlock_post(ctx);
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring: ensure deferred completions are flushed for" failed to apply to 6.1-stable tree
2025-05-12 13:07 ` Jens Axboe
@ 2025-05-12 13:54 ` Greg KH
2025-05-12 13:57 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2025-05-12 13:54 UTC (permalink / raw)
To: Jens Axboe; +Cc: christian.mazakas, norman_maurer, stable
On Mon, May 12, 2025 at 07:07:18AM -0600, Jens Axboe wrote:
> On 5/12/25 4:01 AM, gregkh@linuxfoundation.org wrote:
> >
> > The patch below does not apply to the 6.1-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
>
> Here's a tested 6.1-stable backport.
Thanks for them all, now queued up.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] io_uring: ensure deferred completions are flushed for" failed to apply to 6.1-stable tree
2025-05-12 13:54 ` Greg KH
@ 2025-05-12 13:57 ` Jens Axboe
0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2025-05-12 13:57 UTC (permalink / raw)
To: Greg KH; +Cc: christian.mazakas, norman_maurer, stable
On 5/12/25 7:54 AM, Greg KH wrote:
> On Mon, May 12, 2025 at 07:07:18AM -0600, Jens Axboe wrote:
>> On 5/12/25 4:01 AM, gregkh@linuxfoundation.org wrote:
>>>
>>> The patch below does not apply to the 6.1-stable tree.
>>> If someone wants it applied there, or to any other stable or longterm
>>> tree, then please email the backport, including the original git commit
>>> id to <stable@vger.kernel.org>.
>>
>> Here's a tested 6.1-stable backport.
>
> Thanks for them all, now queued up.
Thanks Greg!
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-12 13:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12 10:01 FAILED: patch "[PATCH] io_uring: ensure deferred completions are flushed for" failed to apply to 6.1-stable tree gregkh
2025-05-12 13:07 ` Jens Axboe
2025-05-12 13:54 ` Greg KH
2025-05-12 13:57 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox