jump_label: Use atomic_try_cmpxchg() in static_key_slow_inc_cpuslocked()
authorUros Bizjak <ubizjak@gmail.com>
Wed, 19 Oct 2022 14:08:50 +0000 (16:08 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 27 Oct 2022 08:35:41 +0000 (10:35 +0200)
commitd0c006402e7941558e5283ae434e2847c7999378
treeb55cbec0a50b075fd546c6713d83d65f8b67d290
parent247f34f7b80357943234f93f247a1ae6b6c3a740
jump_label: Use atomic_try_cmpxchg() in static_key_slow_inc_cpuslocked()

Use atomic_try_cmpxchg() instead of atomic_cmpxchg (*ptr, old, new) ==
old in static_key_slow_inc_cpuslocked().  x86 CMPXCHG instruction
returns success in ZF flag, so this change saves a compare after
cmpxchg (and related move instruction in front of cmpxchg).

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

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20221019140850.3395-1-ubizjak@gmail.com
kernel/jump_label.c