Re: [PATCH V2] asm-generic: ticket-lock: Optimize arch_spin_value_unlocked

From: Will Deacon
Date: Mon Jul 31 2023 - 05:57:17 EST


On Sun, Jul 30, 2023 at 10:33:08PM -0400, guoren@xxxxxxxxxx wrote:
> From: Guo Ren <guoren@xxxxxxxxxxxxxxxxx>
>
> The arch_spin_value_unlocked would cause an unnecessary memory
> access to the contended value. Although it won't cause a significant
> performance gap in most architectures, the arch_spin_value_unlocked
> argument contains enough information. Thus, remove unnecessary
> atomic_read in arch_spin_value_unlocked().
>
> The caller of arch_spin_value_unlocked() could benefit from this
> change. Currently, the only caller is lockref.
>
> Signed-off-by: Guo Ren <guoren@xxxxxxxxxx>
> Cc: Waiman Long <longman@xxxxxxxxxx>
> Cc: David Laight <David.Laight@xxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Signed-off-by: Guo Ren <guoren@xxxxxxxxxxxxxxxxx>
> ---
> Changelog
> V2:
> - Fixup commit log with Waiman advice.
> - Add Waiman comment in the commit msg.
> ---
> include/asm-generic/spinlock.h | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)

Acked-by: Will Deacon <will@xxxxxxxxxx>

It would be nice to see some numbers showing this actually helps, though.

Will