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

Will Deacon will at kernel.org
Mon Jul 31 02:56:23 PDT 2023


On Sun, Jul 30, 2023 at 10:33:08PM -0400, guoren at kernel.org wrote:
> From: Guo Ren <guoren at linux.alibaba.com>
> 
> 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 at kernel.org>
> Cc: Waiman Long <longman at redhat.com>
> Cc: David Laight <David.Laight at ACULAB.COM>
> Cc: Peter Zijlstra <peterz at infradead.org>
> Signed-off-by: Guo Ren <guoren at linux.alibaba.com>
> ---
> 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 at kernel.org>

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

Will



More information about the linux-riscv mailing list