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

Josh Poimboeuf <[email protected]>
Newsgroups org.kernel.vger.linux-toolchains,org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users,org.kernel.vger.linux-trace-kernel
Message-ID <20250123171509.3xmrbrbmu3tsll7w@jpoimboe>
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!

I feel like in_nmi() needs a comment explaining all that nonobviousness.

-- 
Josh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.