forked from Minki/linux
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>
This commit is contained in:
parent
aa06a9bd85
commit
693fc06e98
@ -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;
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user