Commit ebcb324a authored by Uros Bizjak's avatar Uros Bizjak Committed by Greg Kroah-Hartman
Browse files

jump_label: Use atomic_try_cmpxchg() in static_key_slow_inc_cpuslocked()



[ Upstream commit d0c00640 ]

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: default avatarUros Bizjak <ubizjak@gmail.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20221019140850.3395-1-ubizjak@gmail.com


Stable-dep-of: 83ab38ef ("jump_label: Fix concurrency issues in static_key_slow_dec()")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5fd65807
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment