Re: [RFC RESEND v10 03/14] irq & spin_lock: Add counted interrupt disabling/enabling
From: Steven Rostedt
Date: Tue Jun 17 2025 - 11:12:32 EST
On Tue, 17 Jun 2025 07:34:10 -0700
Boqun Feng <boqun.feng@xxxxxxxxx> wrote:
> Because the new local_interrupt_{disable, enable}() participate the
> preempt count game as well, for example, __raw_spin_lock_irq_disable()
> doesn't call an additional preempt_disable() and
> __raw_spin_unlock_irq_enable() doesn't call preempt_enable(). And the
> following can happen:
>
> spin_lock(a);
> // preemption is disabled.
> <interrupted and set need_resched>
>
> spin_lock_irq_disable(b);
>
> spin_unlock(a);
> spin_unlock_irq_enable(b):
> local_interrupt_enable():
> // need to check should_resched, otherwise preemption won't
> // happen.
Ah, because preempt count can be set to non-zero *before* interrupts are
disabled. That makes sense. Thanks.
Hmm, I wonder if we should add a comment stating that here?
-- Steve