From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Uros Bizjak <ubizjak@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15.y 1/4] epoll: use try_cmpxchg in list_add_tail_lockless
Date: Tue, 24 Nov 2026 12:48:07 -0500 [thread overview]
Message-ID: <20261124174758.2019784-1-sashal@kernel.org> (raw)
In-Reply-To: <2026112424-culpable-woof-b14f@gregkh>
From: Uros Bizjak <ubizjak@gmail.com>
[ Upstream commit 693fc06e98514c2d5951ead4aca40cf8b21100b1 ]
Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
list_add_tail_lockless. x86 CMPXCHG instruction returns success in ZF
flag, so this change saves a compare after cmpxchg (and related move
instruction in front of cmpxchg).
No functional change intended.
Link: https://lkml.kernel.org/r/20220714173255.12987-1-ubizjak@gmail.com
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Stable-dep-of: 9f4413e522fa ("eventpoll: wake the next waiter when a woken waiter is killed")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/eventpoll.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 2053d80fb84eb..9e47e1dd66c50 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1155,7 +1155,7 @@ static inline bool list_add_tail_lockless(struct list_head *new,
* added to the list from another CPU: the winner observes
* new->next == new.
*/
- if (cmpxchg(&new->next, new, head) != new)
+ if (!try_cmpxchg(&new->next, &new, head))
return false;
/*
--
2.53.0
next prev parent reply other threads:[~2026-11-24 17:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 16:08 FAILED: patch "[PATCH] eventpoll: wake the next waiter when a woken waiter is killed" failed to apply to 5.15-stable tree gregkh
2026-11-24 17:48 ` Sasha Levin [this message]
2026-11-24 17:48 ` [PATCH 5.15.y 2/4] epoll: Remove ep_scan_ready_list() in comments Sasha Levin
2026-11-24 17:48 ` [PATCH 5.15.y 3/4] eventpoll: Replace rwlock with spinlock Sasha Levin
2026-11-24 17:48 ` [PATCH 5.15.y 4/4] eventpoll: wake the next waiter when a woken waiter is killed Sasha Levin
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=20261124174758.2019784-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=stable@vger.kernel.org \
--cc=ubizjak@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/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