Re: [RFC PATCH v1 0/2] genirq: add migratable NMI registration and show NMI counts
From: Marc Zyngier
Date: Tue Nov 17 2026 - 15:14:46 EST
On Tue, 17 Nov 2026 18:40:14 +0000,
Ashok Raj <ashok.raj@xxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Nov 16, 2026 at 10:31:31AM -0800, Ashok Raj wrote:
> > Hi Vladimir
> >
> >
> > > IIUC, one of the main problems with a shared NMI (as opposed to a
> > > per-CPU) is handling shared state. [...] the same NMI handler could
> > > execute concurrently on two CPUs.
> > >
> > > IIUC, one of the main problems with a shared NMI (as opposed to a
> > > per-CPU) is handling shared state. Consider:
> > >
> > > CPU0 CPU1 CPU2
> > >
> > > ---------------------------------------------------------------------------
> > >
> > > <NMI>
> > > handling started
> > > set NMI affinity to CPU2
> > > <NMI>
> > > handling started
> > > mutate shared state
> > > mutate shared state
> > > handling finished
> > > handling finished
> > >
> > > IOW, the same NMI handler could execute concurrently on two CPUs,
> > > potentially corrupting shared state. Once again more than happy to
> > > be corrected if I missed something :)
> >
> > There is no risk of the same normal, non-per-CPU IRQ action handler
> > executing concurrently on both the previous and newly selected CPUs during
> > an affinity change. Genirq sets IRQD_IRQ_INPROGRESS before dropping the
> > descriptor lock to invoke the driver's hard-IRQ handler. If another instance
> > arrives on the new target while the handler remains active on the previous
> > target, the new CPU observes that in-progress state and does not enter the
> > action handler.
> >
> > The affinity update is not a synchronous “wait for the old CPU” operation:
> > the interrupt controller can route a subsequent interrupt to the new CPU
> > before the old handler returns. However, handler execution remains
> > serialized:
> >
> > Previous CPU New target CPU
> > ------------ --------------
> > set IRQD_IRQ_INPROGRESS
> > drop desc->lock
> > run driver's hard-IRQ handler
> >
> > affinity target is reprogrammed
> > a subsequent IRQ arrives
> > observes IRQD_IRQ_INPROGRESS
> > does not run the action handler
> >
> > handler returns
> > reacquire desc->lock
> > clear IRQD_IRQ_INPROGRESS
> >
> > a later or replayed IRQ may run the
> > action handler on the new CPU
> >
> > Any required pending/replay behavior for an event arriving during this
> > interval is handled by the applicable IRQ flow handler and irqchip semantics;
> > it does not cause simultaneous invocations of the driver's hard-IRQ handler.
> >
> > Does this make sense?
>
> I think what i quoted is true for regular interrupts, but NMI's there is no
> IRQD_IRQ_INPROGRESS serialization. So that overlap as you quote might
> be possible.
>
> I'll need more time to stare at the code and rebase my RFC and post a
> coherent series that uses it to get the full picture.
When you do that, please don't mix functionalities and tests as you
did in the first patch. Slap the tests at the end of the series
instead, as separate patches.
M.
--
Jazz isn't dead. It just smells funny.