Re: [PATCH v4 05/17] irq & spin_lock: Add counted interrupt disabling/enabling

Peter Zijlstra <[email protected]> Wed, 5 Aug 2026 08:36:45 +0200
Newsgroups org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Tue, Aug 04, 2026 at 02:08:11PM -0700, Boqun Feng wrote:

> > > +	/* Interrupts can happen here, but it's OK, see __irq_exit_rcu(). */
> > > +
> > > +	if ((new_count & HARDIRQ_DISABLE_MASK) == HARDIRQ_DISABLE_OFFSET)
> > > +		_local_interrupt_disable();
> > > +}
> > 
> > Maximum nesting possible is 256 right? Whats is stopping here to do more than that?
> 
> Yes. Currently similar as softirq, we don't detect the overflow.
> 
> > Should there be a warn_on?
> 
> A simple warn_on could be problematic because warn_on() itself may take
> an irq-disabling lock, and that may trigger another overflow on top of
> the existing overflow. It's a bit tricky to do a proper detection. But
> I'm open to ideas.

DEBUG_PREEMPT's preempt_count_add() does:

        DEBUG_LOCKS_WARN_ON((preempt_count() & PREEMPT_MASK) >= PREEMPT_MASK - 10);