Re: [PATCH 07/24] locking: Switch to _irq_{disable,enable}() variants in cleanup guards
From: Peter Zijlstra
Date: Mon Aug 03 2026 - 05:42:47 EST
On Fri, Jul 31, 2026 at 01:30:08PM -0700, Boqun Feng wrote:
> From: Boqun Feng <boqun.feng@xxxxxxxxx>
>
> The semantics of various irq disabling guards match what
> *_irq_{disable,enable}() provide, i.e. the interrupt disabling is
> properly nested, therefore it's OK to switch to use
> *_irq_{disable,enable}() primitives.
>
> Signed-off-by: Boqun Feng <boqun@xxxxxxxxxx>
> Link: https://patch.msgid.link/20260121223933.1568682-17-lyude@xxxxxxxxxx
> ---
> include/linux/spinlock.h | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
> index 3d405cc4c121..a9d169dad6d4 100644
> --- a/include/linux/spinlock.h
> +++ b/include/linux/spinlock.h
> @@ -572,12 +572,12 @@ DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_nested, __acquires(_T), __releases(*(raw
> #define class_raw_spinlock_nested_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_nested, _T)
>
> DEFINE_LOCK_GUARD_1(raw_spinlock_irq, raw_spinlock_t,
> - raw_spin_lock_irq(_T->lock),
> - raw_spin_unlock_irq(_T->lock))
> + raw_spin_lock_irq_disable(_T->lock),
> + raw_spin_unlock_irq_enable(_T->lock))
> DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irq, __acquires(_T), __releases(*(raw_spinlock_t **)_T))
> #define class_raw_spinlock_irq_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irq, _T)
>
> -DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irq, _try, raw_spin_trylock_irq(_T->lock))
> +DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irq, _try, raw_spin_trylock_irq_disable(_T->lock))
> DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irq_try, __acquires(_T), __releases(*(raw_spinlock_t **)_T))
> #define class_raw_spinlock_irq_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irq_try, _T)
>
> @@ -618,13 +618,13 @@ DECLARE_LOCK_GUARD_1_ATTRS(spinlock_try, __acquires(_T), __releases(*(spinlock_t
> #define class_spinlock_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_try, _T)
>
> DEFINE_LOCK_GUARD_1(spinlock_irq, spinlock_t,
> - spin_lock_irq(_T->lock),
> - spin_unlock_irq(_T->lock))
> + spin_lock_irq_disable(_T->lock),
> + spin_unlock_irq_enable(_T->lock))
> DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irq, __acquires(_T), __releases(*(spinlock_t **)_T))
> #define class_spinlock_irq_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irq, _T)
>
> DEFINE_LOCK_GUARD_1_COND(spinlock_irq, _try,
> - spin_trylock_irq(_T->lock))
> + spin_trylock_irq_disable(_T->lock))
> DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irq_try, __acquires(_T), __releases(*(spinlock_t **)_T))
> #define class_spinlock_irq_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irq_try, _T)
What about the _irqsave() guards?
Is the goal to replace _irqsave guard usage with _irq and then remove
the _irqsave guards?
If so, this should probably we mentioned somewhere.