Re: [PATCH] locking: Revert switching guards to _irq_{disable,enable}()

From: Thomas Gleixner

Date: Sun Aug 30 2026 - 16:01:23 EST


On Sat, Aug 29 2026 at 16:37, Boqun Feng wrote:
> On Sat, Aug 29, 2026 at 01:11:56AM +0200, Thomas Gleixner wrote:
>> +static __always_inline void __raw_local_irq_restore(unsigned long cnt)
>> +{
>> + debug_assert((preempt_count() & HARDIRQ_DISABLE_MASK) == (cnt + HARDIRQ_DISABLE_OFFSET));
>> +
>> + if (!(__preempt_count_sub_return(HARDIRQ_DISABLE_OFFSET) & HARDIRQ_DISABLE_MASK))
>> + arch_local_irq_enable();
>> +}
>
> And while we are at, we can just introduce a
> raw_local_irq_restore_auto() (definitely needs a better name), which
> doesn't need a cnt:
>
> static __always_inline void __raw_local_irq_restore_auto(void)
> {
> debug_assert((preempt_count() & HARDIRQ_DISABLE_MASK));
>
> if (!(__preempt_count_sub_return(HARDIRQ_DISABLE_OFFSET) & HARDIRQ_DISABLE_MASK))
> arch_local_irq_enable();
> }

Yes, we can add something like this once we got the design and the debug
infrastructure in place. For now the count is helpful to debug stuff and
we want to have something equivalent at least for lockdep builds.

Thanks,

tglx