Re: [PATCH v2 7/9] sched: define TIF_ALLOW_RESCHED

Peter Zijlstra
2023-09-09T09:12:23Z

On Fri, Sep 08, 2023 at 10:30:57PM -0700, Ankur Arora wrote:

> > which actually makes me worry about the nested irq case, because this
> > would *not* be ok:
> >
> > allow_resched();
> > -> irq happens
> > -> *nested* irq happens
> > <- nested irq return (andapreemption)
> >
> > ie the allow_resched() needs to still honor the irq count, and a
> > nested irq return obviously must not cause any preemption.
>
> IIUC, this should be equivalent to:
>
> 01 allow_resched();
> 02 -> irq happens
> 03 preempt_count_add(HARDIRQ_OFFSET);
> 04 -> nested irq happens
> 05 preempt_count_add(HARDIRQ_OFFSET);
> 06
> 07 preempt_count_sub(HARDIRQ_OFFSET);
> 08 <- nested irq return
> 09 preempt_count_sub(HARDIRQ_OFFSET);
>
> So, even if there were nested interrrupts, then the !preempt_count()
> check in raw_irqentry_exit_cond_resched() should ensure that no
> preemption happens until after line 09.

Yes, this.