Skip to contentSkip to conversation

FAILED: patch "[PATCH] io_uring/poll: avoid retry wakeup loss when dropping" failed to apply to 5.15-stable tree

PATCH New [email protected] 2 participants 2 messages Oct 28

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-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 <[email protected]>.

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-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 937d38dcacd675dc0572d6c9b6743960df3128ed
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026102833-buffing-shone-0fb5@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 937d38dcacd675dc0572d6c9b6743960df3128ed Mon Sep 17 00:00:00 2001
From: Juanlu Herrero <[email protected]>
Date: Tue, 13 Oct 2026 15:37:20 -0700
Subject: [PATCH] io_uring/poll: avoid retry wakeup loss when dropping
ownership

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.

Fixes a26a35e9019f ("io_uring: make poll refs more robust")
Assisted-by LLM
io_uring/poll.c +2 -1
index 7dcb904e8fc3..704a9b6102a9 100644
@@ -330,7 +330,8 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)
 		 * Release all references, retry if someone tried to restart
 		 * task_work while we were executing it.
 		 */
-	} while (atomic_sub_return(v, &req->poll_refs) & IO_POLL_REF_MASK);
+		v &= IO_POLL_REF_MASK;
+	} while (atomic_cmpxchg(&req->poll_refs, v, 0) != v);
 
 	io_napi_add(req);
 	return IOU_POLL_NO_ACTION;
maintainer
#1 lore raw

PATCH 1/1 io_uring/poll: avoid retry wakeup loss when dropping ownership

From: Juanlu Herrero <[email protected]>

[ 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.

Fixes a26a35e9019f ("io_uring: make poll refs more robust")
Assisted-by LLM
[ sashal: Relocated the change to io_poll_check_events() in the monolithic io_uring implementation. ]
---
 io_uring/io_uring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
io_uring/io_uring.c +2 -2
index 8d5791d8f4031..a87b24c77c0ee 100644
@@ -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;
 }
Signature · 1 line
2.53.0