Re: [RFC RESEND v10 03/14] irq & spin_lock: Add counted interrupt disabling/enabling
From: Steven Rostedt
Date: Tue Jun 17 2025 - 10:22:31 EST
On Tue, 27 May 2025 18:21:44 -0400
Lyude Paul <lyude@xxxxxxxxxx> wrote:
> +static inline void local_interrupt_enable(void)
> +{
> + int new_count;
> +
> + new_count = hardirq_disable_exit();
> +
> + if ((new_count & HARDIRQ_DISABLE_MASK) == 0) {
> + unsigned long flags;
> +
> + flags = raw_cpu_read(local_interrupt_disable_state.flags);
> + local_irq_restore(flags);
> + /*
> + * TODO: re-read preempt count can be avoided, but it needs
> + * should_resched() taking another parameter as the current
> + * preempt count
> + */
> +#ifdef PREEMPTION
> + if (should_resched(0))
> + __preempt_schedule();
> +#endif
> + }
> +}
I'm confused to why the should_resched() is needed? We are handling
interrupts right? The hardirq_disable_exit() will set preempt_count to zero
before we enable interrupts. When the local_irq_restore() enables interrupts
again, if there's an interrupt pending it will trigger then. If the
interrupt sets NEED_RESCHED, when it returns from the interrupt handler, it
will see preempt_count as zero, right?
If it does, then it will call schedule before it gets back to this code.
-- Steve