Skip to content

Commit 9109566

Browse files
ubizjakingomolnar
authored andcommitted
locking/pvqspinlock/x86: Remove redundant CMP after CMPXCHG in __raw_callee_save___pv_queued_spin_unlock()
x86 CMPXCHG instruction returns success in the ZF flag. Remove redundant CMP instruction after CMPXCHG that performs the same check. Also update the function comment to mention the modern version of the equivalent C code. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20240412083908.282802-1-ubizjak@gmail.com
1 parent fea0e18 commit 9109566

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

arch/x86/include/asm/qspinlock_paravirt.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
2525
*
2626
* void __lockfunc __pv_queued_spin_unlock(struct qspinlock *lock)
2727
* {
28-
* u8 lockval = cmpxchg(&lock->locked, _Q_LOCKED_VAL, 0);
28+
* u8 lockval = _Q_LOCKED_VAL;
2929
*
30-
* if (likely(lockval == _Q_LOCKED_VAL))
30+
* if (try_cmpxchg(&lock->locked, &lockval, 0))
3131
* return;
3232
* pv_queued_spin_unlock_slowpath(lock, lockval);
3333
* }
@@ -43,7 +43,6 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
4343
"mov $0x1,%eax\n\t" \
4444
"xor %edx,%edx\n\t" \
4545
LOCK_PREFIX "cmpxchg %dl,(%rdi)\n\t" \
46-
"cmp $0x1,%al\n\t" \
4746
"jne .slowpath\n\t" \
4847
"pop %rdx\n\t" \
4948
FRAME_END \

0 commit comments

Comments
 (0)