The patch titled Subject: epoll: use try_cmpxchg in list_add_tail_lockless has been added to the -mm mm-nonmm-unstable branch. Its filename is epoll-use-try_cmpxchg-in-list_add_tail_lockless.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/epoll-use-try_cmpxchg-in-list_add_tail_lockless.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Uros Bizjak <ubizjak@xxxxxxxxx> Subject: epoll: use try_cmpxchg in list_add_tail_lockless Date: Thu, 14 Jul 2022 19:32:55 +0200 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@xxxxxxxxx Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/eventpoll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/eventpoll.c~epoll-use-try_cmpxchg-in-list_add_tail_lockless +++ a/fs/eventpoll.c @@ -1065,7 +1065,7 @@ static inline bool list_add_tail_lockles * 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; /* _ Patches currently in -mm which might be from ubizjak@xxxxxxxxx are llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch epoll-use-try_cmpxchg-in-list_add_tail_lockless.patch