diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2023-05-09 17:02:55 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2023-10-10 10:14:27 +0200 |
commit | 4fbf8b136ded943f8661cf48270482ad1f5ce7bd (patch) | |
tree | 6791e499a8533413fffe2b4d0b59f04e2aa1f8f1 /lib/earlycpio.c | |
parent | ad0a2e4c2f20510d7e3f2bc110cf74f8578547f0 (diff) |
locking/atomics: Use atomic_try_cmpxchg_release() to micro-optimize rcuref_put_slowpath()
Use atomic_try_cmpxchg() instead of atomic_cmpxchg(*ptr, old, new) == old
in rcuref_put_slowpath(). On x86 the CMPXCHG instruction returns success in the
ZF flag, so this change saves a compare after CMPXCHG. Additionaly,
the compiler reorders some code blocks to follow likely/unlikely
annotations in the atomic_try_cmpxchg() macro, improving the code from:
9a: f0 0f b1 0b lock cmpxchg %ecx,(%rbx)
9e: 83 f8 ff cmp $0xffffffff,%eax
a1: 74 04 je a7 <rcuref_put_slowpath+0x27>
a3: 31 c0 xor %eax,%eax
to:
9a: f0 0f b1 0b lock cmpxchg %ecx,(%rbx)
9e: 75 4c jne ec <rcuref_put_slowpath+0x6c>
a0: b0 01 mov $0x1,%al
No functional change intended.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Link: https://lore.kernel.org/r/20230509150255.3691-1-ubizjak@gmail.com
Diffstat (limited to 'lib/earlycpio.c')
0 files changed, 0 insertions, 0 deletions