Re: [PATCH v5] softirq: Preserve interrupt context during IRQ exit

From: Karl Mehltretter

Date: Fri Oct 09 2026 - 13:12:15 EST


Hi Frederic,

Thanks for the review!

On Tue, Oct 06, 2026 at 12:00:51PM +0200, Frederic Weisbecker wrote:
> > +static inline bool softirq_handle_begin(void)
> > {
> > - __local_bh_disable_ip(_RET_IP_, SOFTIRQ_OFFSET);
> > + bool from_irq_exit = in_hardirq();
> > +
> > + if (!from_irq_exit) {
>
> Is this variable necessary?

No. I'll drop it.

> > + /*
> > + * Wake the timer thread even if the interrupt hit a softirq or a
> > + * section with BHs disabled. Only nested interrupts and NMIs are
> > + * excluded.
> > + */
> > if (IS_ENABLED(CONFIG_IRQ_FORCED_THREADING) && force_irqthreads() &&
> > - local_timers_pending_force_th() && !(in_nmi() | in_hardirq()))
> > + local_timers_pending_force_th() &&
> > + (in_nmi() | hardirq_count()) == HARDIRQ_OFFSET)
>
> NMIs shouldn't ever take this path, right?

Good catch. I'll drop the in_nmi() test.

> > + /*
> > + * tick_irq_exit() relies on in_hardirq() being false for the
> > + * outermost interrupt.
> > + */
> > + preempt_count_sub(HARDIRQ_OFFSET);
> > tick_irq_exit();
>
> Can we also extend the HARDIRQ_OFFSET context coverage to tick_irq_exit() ?
> From a quick look I haven't found anything that would prevent from that. You just need
> to turn the "if (!in_hardirq())" test to "if hardirq_count()) == HARDIRQ_OFFSET"

Yes. I checked the rest of the tick-exit path and found no other
dependency on HARDIRQ_OFFSET being clear. I'll make that change.

Karl