On Fri, Sep 08, 2023 at 10:15:07AM -0700, Linus Torvalds wrote: > On Fri, 8 Sept 2023 at 00:03, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote: > > > > Which on a PREEMPT_COUNT=n build will cause preemption while holding the > > spinlock. I think something like the below will cause sufficient > > warnings to avoid growing patterns like that. > > Hmm. I don't think that warning is valid. > > Disabling preemption is actually fine if it's done in an interrupt, > iow if we have > > allow_resched(); > -> irq happens > spin_lock(); // Ok and should *not* complain > ... > spin_unlock(); > <- irq return (and preemption) Indeed. > > 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 (and preemption) > > ie the allow_resched() needs to still honor the irq count, and a > nested irq return obviously must not cause any preemption. I think we killed nested interrupts a fair number of years ago, but I'll recheck -- but not today, sleep is imminent.