Re: [PATCH v4 01/39] task_work: Fix TWA_NMI_CURRENT error handling

Peter Zijlstra
2025-01-23T22:19:13Z

On Thu, Jan 23, 2025 at 09:15:09AM -0800, Josh Poimboeuf wrote:
> On Thu, Jan 23, 2025 at 09:14:03AM +0100, Peter Zijlstra wrote:
> > On Wed, Jan 22, 2025 at 12:47:20PM -0800, Josh Poimboeuf wrote:
> > > What exactly do you mean by "NMI like"? Is it because a #DB might be
> > > basically running in NMI context, if the NMI hit a breakpoint?
> >
> > No, #DB, #BP and such are considered NMI (and will have in_nmi() true)
> > because they can trigger anywhere, including sections where IRQs are
> > disabled.
>
> So:
>
> - while exceptions are technically not NMI, they're "NMI" because they
> can occur in NMI or IRQ-disabled regions
>
> - such "NMI" exceptions can be preempted by NMIs and "NMIs"
>
> - NMIs can be preempted by "NMIs" but not NMIs (except in entry code!)
>
> ... did I get all that right? Not subtle at all!

Yeah, sounds about right :-)