* [PATCH] epoll: Use try_cmpxchg in list_add_tail_lockless
@ 2022-07-14 17:32 Uros Bizjak
0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2022-07-14 17:32 UTC (permalink / raw)
To: linux-fsdevel, linux-kernel; +Cc: Uros Bizjak, Alexander Viro
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.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
---
fs/eventpoll.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index e2daa940ebce..6705cb965fbe 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1065,7 +1065,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.35.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-14 17:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-14 17:32 [PATCH] epoll: Use try_cmpxchg in list_add_tail_lockless Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).