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:Uros Bizjak <ubizjak@gmail.com> Reviewed-by:
Alexey Gladkov <legion@kernel.org> Link: https://lkml.kernel.org/r/20221017144049.3404-3-ubizjak@gmail.com Signed-off-by:
Eric W. Biederman <ebiederm@xmission.com>
Loading
Please register or sign in to comment