locking/pvqspinlock: Use try_cmpxchg_acquire() in trylock_clear_pending()
authorUros Bizjak <ubizjak@gmail.com>
Mon, 25 Mar 2024 14:09:32 +0000 (15:09 +0100)
committerIngo Molnar <mingo@kernel.org>
Fri, 12 Apr 2024 09:40:51 +0000 (11:40 +0200)
commit6a97734f2222e0352f1900e3eb3167e9069b91bb
treeaeb9a451bb6965ca8c42f5f259a3aed935687624
parent79a34e3d8411050c3c7550c5163d6f9dc41e8f66
locking/pvqspinlock: Use try_cmpxchg_acquire() in trylock_clear_pending()

Replace this pattern in trylock_clear_pending():

    cmpxchg_acquire(*ptr, old, new) == old

... with the simpler and faster:

    try_cmpxchg_acquire(*ptr, &old, new)

The x86 CMPXCHG instruction returns success in the ZF flag, so this change
saves a compare after the CMPXCHG.

Also change the return type of the function to bool and streamline
the control flow in the _Q_PENDING_BITS == 8 variant a bit.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Waiman Long <longman@redhat.com>
Reviewed-by: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20240325140943.815051-1-ubizjak@gmail.com
kernel/locking/qspinlock_paravirt.h