Re: [PATCH v7 1/5] locking/qspinlock: Rename mcs lock/unlock macros and make them more generic

Peter Zijlstra
2020-01-22T09:16:12Z

On Mon, Nov 25, 2019 at 04:07:05PM -0500, Alex Kogan wrote:

> --- a/arch/arm/include/asm/mcs_spinlock.h
> +++ b/arch/arm/include/asm/mcs_spinlock.h
> @@ -6,7 +6,7 @@
> #include <asm/spinlock.h>
>
> /* MCS spin-locking. */
> -#define arch_mcs_spin_lock_contended(lock) \
> +#define arch_mcs_spin_lock(lock) \
> do { \
> /* Ensure prior stores are observed before we enter wfe. */ \
> smp_mb(); \
> @@ -14,9 +14,9 @@ do { \
> wfe(); \
> } while (0) \
>
> -#define arch_mcs_spin_unlock_contended(lock) \
> +#define arch_mcs_pass_lock(lock, val) \
> do { \
> - smp_store_release(lock, 1); \
> + smp_store_release((lock), (val)); \
> dsb_sev(); \
> } while (0)

So I hate those names; it used to be clear this was the contended path,
not so anymore. arch_mcs_spin_lock() in particular is grossly misnamed
now.

's/arch_mcs_spin_lock/arch_mcs_spin_wait/g' could perhaps work, if you
really want to get rid of the _contended suffix.

Also, pass_lock seems unfortunately named...