Skip to content
Commit b4b11b58 authored by Uros Bizjak's avatar Uros Bizjak Committed by Eric W. Biederman
Browse files

ucount: Use atomic_long_try_cmpxchg in atomic_long_inc_below



Use atomic_long_try_cmpxchg instead of
atomic_long_cmpxchg (*ptr, old, new) == old in atomic_long_inc_below.
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_long_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>
Reviewed-by: default avatarAlexey Gladkov <legion@kernel.org>
Link: https://lkml.kernel.org/r/20221017144049.3404-3-ubizjak@gmail.com


Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
parent 295227b1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment