Commit 693fc06e authored by Uros Bizjak's avatar Uros Bizjak Committed by Andrew Morton
Browse files

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: default avatarUros Bizjak <ubizjak@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent aa06a9bd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;

	/*