Re: [PATCH 07/24] locking: Switch to _irq_{disable,enable}() variants in cleanup guards
Boqun Feng <[email protected]> Mon, 3 Aug 2026 06:46:19 -0700
| Newsgroups | org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Aug 03, 2026 at 11:34:33AM +0200, Peter Zijlstra wrote: > On Fri, Jul 31, 2026 at 01:30:08PM -0700, Boqun Feng wrote: > > From: Boqun Feng <[email protected]> > > > > 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 <[email protected]> > > Link: https://patch.msgid.link/[email protected] > > --- > > 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? > Yes, that's the goal. I had that in previous version. However in 1abbecd1d2d2 ("sched/fair: Convert cfs bandwidth throttling to use guards"), we have a user that explicitly plays with the .flags in guard. Lyude also spotted that too. We could adjust that user to the new API (Lyude already has the diff for that) but I decided to simply drop that part for now given the current size of the changes. But if you think it's a must for merge this, I will add it. > If so, this should probably we mentioned somewhere. I will at least add this part. Thanks! Regards, Boqun