]> git.baikalelectronics.ru Git - kernel.git/commit
llist: use try_cmpxchg in llist_add_batch and llist_del_first
authorUros Bizjak <ubizjak@gmail.com>
Tue, 12 Jul 2022 14:49:17 +0000 (16:49 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 Sep 2022 04:55:06 +0000 (21:55 -0700)
commit0e966edc0d16e08bb303d751cd5b031f46f1e415
treeb149575bb927d0552a63441ab885a5a9128212f3
parent03bc427430f69e309fc49b2b16c9c7fe7fba373e
llist: use try_cmpxchg in llist_add_batch and llist_del_first

Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
llist_add_batch and llist_del_first.  x86 CMPXCHG instruction returns
success in ZF flag, so this change saves a compare after cmpxchg.

Also, try_cmpxchg implicitly assigns old *ptr value to "old" when cmpxchg
fails, enabling further code simplifications.

No functional change intended.

Link: https://lkml.kernel.org/r/20220712144917.4497-1-ubizjak@gmail.com
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/llist.c