aboutsummaryrefslogtreecommitdiffstats
path: root/fs/eventpoll.c
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2022-07-14 19:32:55 +0200
committerAndrew Morton <akpm@linux-foundation.org>2022-09-11 21:55:07 -0700
commit693fc06e98514c2d5951ead4aca40cf8b21100b1 (patch)
tree442f100b654ab0af29f2e068850c0d88eb1fbe5f /fs/eventpoll.c
parentia64: fix clock_getres(CLOCK_MONOTONIC) to report ITC frequency (diff)
downloadlinux-dev-693fc06e98514c2d5951ead4aca40cf8b21100b1.tar.xz
linux-dev-693fc06e98514c2d5951ead4aca40cf8b21100b1.zip
epoll: use try_cmpxchg in list_add_tail_lockless
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>
Diffstat (limited to 'fs/eventpoll.c')
-rw-r--r--fs/eventpoll.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 8b56b94e2f56..52954d4637b5 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;
/*