From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Juanlu Herrero <juanlu@fastmail.com>,
Anand Natarajan <anand@meta.com>, Jens Axboe <axboe@kernel.dk>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15.y] io_uring/poll: avoid retry wakeup loss when dropping ownership
Date: Wed, 28 Oct 2026 12:16:58 -0400 [thread overview]
Message-ID: <20261028161609.942683-1-sashal@kernel.org> (raw)
In-Reply-To: <2026102833-buffing-shone-0fb5@gregkh>
From: Juanlu Herrero <juanlu@fastmail.com>
[ Upstream commit 937d38dcacd675dc0572d6c9b6743960df3128ed ]
If a wakeup sets IO_POLL_RETRY_FLAG between the owning task consuming
the existing instance of IO_POLL_RETRY_FLAG and the loop check
of io_poll_check_events(), then we stall on processing the request
until an unrelated wakeup comes along.
Using atomic_cmpxchg instead of atomic_sub_return to guarantee both the
count v and poll_refs are 0 and no wake-ups are missed.
Cc: stable@vger.kernel.org
Fixes: a26a35e9019f ("io_uring: make poll refs more robust")
Signed-off-by: Juanlu Herrero <juanlu@fastmail.com>
Assisted-by: LLM
Suggested-by: Anand Natarajan <anand@meta.com>
Link: https://patch.msgid.link/20261013-pu-cmpxchg-v1-1-4ddc10fd8a03@fastmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[ sashal: Relocated the change to io_poll_check_events() in the monolithic io_uring implementation. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
io_uring/io_uring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 8d5791d8f4031..a87b24c77c0ee 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -5690,8 +5690,8 @@ static int io_poll_check_events(struct io_kiocb *req)
* Release all references, retry if someone tried to restart
* task_work while we were executing it.
*/
- } while (atomic_sub_return(v & IO_POLL_REF_MASK, &req->poll_refs) &
- IO_POLL_REF_MASK);
+ v &= IO_POLL_REF_MASK;
+ } while (atomic_cmpxchg(&req->poll_refs, v, 0) != v);
return 1;
}
--
2.53.0
prev parent reply other threads:[~2026-10-28 16:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 14:17 FAILED: patch "[PATCH] io_uring/poll: avoid retry wakeup loss when dropping" failed to apply to 5.15-stable tree gregkh
2026-10-28 16:16 ` Sasha Levin [this message]
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=20261028161609.942683-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=anand@meta.com \
--cc=axboe@kernel.dk \
--cc=juanlu@fastmail.com \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox