smpboot: use atomic_try_cmpxchg in cpu_wait_death and cpu_report_death
authorUros Bizjak <ubizjak@gmail.com>
Thu, 25 Aug 2022 14:56:03 +0000 (16:56 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 Sep 2022 04:55:10 +0000 (21:55 -0700)
commit9a15193e23b780d1da77e3db18698beb0637897d
tree789af806d1dfa280b4c6ef05d8dd5038fe855b89
parent5fdfa161b2043001f82cbce49e87e8e9f581d510
smpboot: use atomic_try_cmpxchg in cpu_wait_death and cpu_report_death

Use atomic_try_cmpxchg instead of atomic_cmpxchg (*ptr, old, new) == old
in cpu_wait_death and cpu_report_death.  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.

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