Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Murzin <vladimir.murzin@arm.com>
To: Ashok Raj <ashok.raj@oss.qualcomm.com>
Cc: Linux ARM Kernel <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Jinjie Ruan <ruanjinjie@huawei.com>,
	Liaochang <liaochang1@huawei.com>, Marc Zyngier <maz@kernel.org>,
	Radu Rendec <radu@rendec.net>,
	Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>,
	Sathvika Vasireddy <sathvika.vasireddy@oss.qualcomm.com>
Subject: Re: [RFC PATCH v1 0/2] genirq: add migratable NMI registration and show NMI counts
Date: Thu, 19 Nov 2026 11:15:28 +0000	[thread overview]
Message-ID: <df0647cd-c874-4fc7-b167-af65edcedd19@arm.com> (raw)
In-Reply-To: <av0EE35H57DWF1E2@hu-ashoraj-lv.qualcomm.com>

Hi Ashok,

Sorry for delaying reply... got caught by sorting out Sashiko comments on
FEAT_NMI :) 

On 11/18/26 01:49, Ashok Raj wrote:
> Hi Vladimir
> 
> On Mon, Nov 16, 2026 at 10:38:00AM +0000, Vladimir Murzin wrote:
>> Hi Ashok,
>>
>> On 11/14/26 23:49, Ashok Raj wrote:
>>> request_nmi() currently models NMIs as per-CPU sources. This does not
>>> represent a globally routed NMI source with an affinity-capable irqchip,
>>> which needs to be rerouted when its target CPU is offlined.
>>>
>>> This RFC adds IRQF_NMI_MIGRATABLE as a request_nmi() registration mode
>>> for such a source. It remains excluded from normal IRQ balancing, but the
>>> generic startup and CPU-hotplug paths may select an online target. The
>>> second patch fixes the related /proc/interrupts display: NMI-safe flow
>>> handling updates the per-CPU counters rather than irq_desc::tot_count.
>>>
>>> Patch 1: Add the migratable-NMI registration mode, validate that it is
>>> used only through request_nmi() with an affinity-capable non-per-CPU
>>> irqchip, and add IRQ KUnit coverage for registration and CPU-offline
>>> migration.
>>>
>>> Patch 2: Emit the per-CPU counters for all NMI descriptors, matching
>>> kstat_irqs_desc().
>>>
>>> Testing:
>>>   - ARM64 changed-object builds with WERROR=1
>>>   - ARM64 !SMP changed-object build
>>>   - ARM64 IRQ KUnit run under QEMU with two CPUs, including registration
>>>     validation and CPU-offline migration
>>>   - local downstream GHES delivery and migration validation for the intended
>>>     consumer topology (not part of this series)
>>>
>>> Base and dependencies:
>>>
>>> This RFC was developed and tested on v7.4-rc2 plus the FEAT_NMI v2 series
>>> [1]. It depends on that series' GIC NMI support and is therefore not directly
>>> applicable to mainline or linux-next as posted. This RFC is for design
>>> feedback; it will need rebasing onto the upstream form of those prerequisites
>>> before submission.
>>>
>>> [1] https://lore.kernel.org/linux-arm-kernel/20261112132042.129062-1-vladimir.murzin@arm.com/
>>>
>> I'm not an expert in this area, but based on what I've learned so far,
>> NMI being per-CPU like makes life much easier ;)
>>
>> 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 :)
>>
> Thanks, you're right, and I got it wrong in my earlier reply. genirq
> doesn't serialize NMI handlers: handle_fasteoi_nmi() takes no desc->lock
> and sets no IRQD_IRQ_INPROGRESS.
> 

Matches my observation.

> These interrupts are external interrupts in the platform, not Per CPU
> interrupts like the perf kinds. 
> 

Correct, that why I call them per-CPU like :)

> I'm new to the GIC, so I'd like to check an assumption. On GICv3, an
> active SPI isn't signalled again until it is deactivated.
> handle_fasteoi_nmi() calls chip->irq_eoi() only after the handler
> returns. 
> 

Yes.

> So I'm assuming a second CPU can't be sent the same SPI while
> the first CPU is still in the handler.
> 
> Is that a reasonable assumption? 

Perhaps. I'm still trying to understand where is border between what
we can assume and what we must guaranty, especially when it comes to
generic implementation. 

> 
> I didn't quite follow the mutate shared state comment. 
> 

That's generic statement since NMI flow doesn't take locks. I still
need to understand what and why IRQ flow protects with locks and how
it relates to NMI flow... Sorry for making such vague statements!

Ideally, for generic support for global NMIs (opposite to per-CPU,
I do not use term "shared" since it confuses people with IRQ_SHARED
which is not in scope here!) we want requestor just omit IRQF_PERCPU
and the generic flow do the right thing automatically. That requires
enumerating corer cases due to NMI is not per-CPU anymore and providing
measures to either avoid those cases or handle them or likely balance
between both. I'm spending some spare cycles on that, but things go
slowly...

Cheers
Vladimir

> I just interpreted thast as "handler is now called in another CPU" 
> type assumption.
> 
> Cheers,
> Ashok
> 



      reply	other threads:[~2026-11-19 11:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 23:49 [RFC PATCH v1 0/2] genirq: add migratable NMI registration and show NMI counts Ashok Raj
2026-11-14 23:49 ` [RFC PATCH v1 1/2] genirq: Add migratable NMI registration mode Ashok Raj
2026-11-14 23:49 ` [RFC PATCH v1 2/2] genirq/proc: Show NMI interrupt counts in /proc/interrupts Ashok Raj
2026-11-16 10:38 ` [RFC PATCH v1 0/2] genirq: add migratable NMI registration and show NMI counts Vladimir Murzin
2026-11-16 18:31   ` Ashok Raj
2026-11-17 18:40     ` Ashok Raj
2026-11-17 20:18       ` Marc Zyngier
2026-11-17 22:39         ` Ashok Raj
2026-11-18  1:49   ` Ashok Raj
2026-11-19 11:15     ` Vladimir Murzin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df0647cd-c874-4fc7-b167-af65edcedd19@arm.com \
    --to=vladimir.murzin@arm.com \
    --cc=ashok.raj@oss.qualcomm.com \
    --cc=catalin.marinas@arm.com \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=liaochang1@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=radu@rendec.net \
    --cc=ruanjinjie@huawei.com \
    --cc=sathvika.vasireddy@oss.qualcomm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox