mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kiryl Shutsemau (Meta)" <kas@kernel.org>
To: YinFengwei <fengwei_yin@linux.alibaba.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	 Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	 James Morse <james.morse@arm.com>,
	Jinjie Ruan <ruanjinjie@huawei.com>,
	 Vladimir Murzin <vladimir.murzin@arm.com>,
	Ada Couprie Diaz <ada.coupriediaz@arm.com>,
	 Marc Zyngier <maz@kernel.org>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	 Liao Chang <liaochang1@huawei.com>,
	Ashok Raj <ashok.raj@oss.qualcomm.com>,
	 Doug Anderson <dianders@chromium.org>,
	Pengjie Zhang <zhangpengjie2@huawei.com>,
	 Cong Wang <cwang@multikernel.io>,
	kernel-team@meta.com, linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 1/2] firmware: arm_sdei: Do not signal event 0 to a masked PE
Date: Wed, 25 Nov 2026 14:00:40 +0000	[thread overview]
Message-ID: <awblcOnI8JVhpmPK@shutemov.name> (raw)
In-Reply-To: <awavUsKX4XLRMbUq@U-V2QX163P-2032.local>

On Wed, Nov 25, 2026 at 05:50:10PM +0800, YinFengwei wrote:
> Hi Kirill,
> 
> On Tue, Nov 24, 2026 at 07:47:04PM +0000, Kiryl Shutsemau (Meta) wrote:
> > The SDEI NMI backtrace signals event 0 to every other CPU, idle ones
> <snip>
> > +static void sdei_block_signal(void)
> > +{
> > +	struct sdei_pe *pe = this_cpu_ptr(&sdei_pe);
> > +	unsigned long flags;
> > +
> > +	/*
> > +	 * A panic from an SDEI event or a pseudo-NMI may have left the lock
> > +	 * held by this CPU. The CPUs that could signal it are stopped by now.
> > +	 */
> > +	if (panic_on_this_cpu()) {
> > +		WRITE_ONCE(pe->unmasked, false);
> If the panic didn't take the lock, should lock be taken
> just like "else" path?

If another CPU holds it at this point, that CPU was stopped in the
middle of signalling this one, and it will never drop the lock. The
panic would hang on it.

If nobody holds it, there is nothing for it to keep out. This runs at
the end of smp_send_stop(), after the other CPUs have been stopped. A
sender stopped after it took the lock has either counted its signal,
which sdei_wait_in_flight() waits for, or never sent one.

Telling the two apart takes a trylock, and on failure we would go ahead
without the lock anyway.

> > +	} else {
> > +		raw_spin_lock_irqsave(&pe->lock, flags);
> > +		WRITE_ONCE(pe->unmasked, false);
> > +		raw_spin_unlock_irqrestore(&pe->lock, flags);
> > +	}
> > +
> > +	sdei_wait_in_flight(pe);
> > +}
> > +
> >  static int sdei_pm_notifier(struct notifier_block *nb, unsigned long action,
> >  			    void *data)
> >  {
> > +	struct sdei_pe *pe = this_cpu_ptr(&sdei_pe);
> >  	int rv;
> >  
> >  	WARN_ON_ONCE(preemptible());
> >  
> >  	switch (action) {
> >  	case CPU_PM_ENTER:
> > +		/*
> > +		 * Leave alone a PE that is masked already: before
> > +		 * sdei_cpuhp_up(), or after sdei_cpuhp_down(), as cpuidle runs
> > +		 * until CPU_OFF. CPU_PM_EXIT must not unmask it.
> > +		 */
> > +		if (!pe->unmasked)
> I am wondering whether READ_ONCE() should be used here?

No.

We read the flag of this CPU, and only this CPU writes pe->unmasked.
The notifier runs with IRQs off, so no store can race with this load.

What can still interrupt it, a stop or a panic from an SDEI event or a
pseudo-NMI, does not return here.

READ_ONCE()/WRITE_ONCE() are for sdei_event_signal(), which reads the
flag from another CPU.

Left plain, KCSAN will report it if that ever changes. See item 5 under
"Use of Plain C-Language Accesses" in
tools/memory-model/Documentation/access-marking.txt.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

  reply	other threads:[~2026-11-25 14:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 19:47 [PATCH 0/2] firmware: arm_sdei: Fix NMI backtrace lockups on idle CPUs Kiryl Shutsemau (Meta)
2026-11-24 19:47 ` [PATCH 1/2] firmware: arm_sdei: Do not signal event 0 to a masked PE Kiryl Shutsemau (Meta)
2026-11-25  9:50   ` YinFengwei
2026-11-25 14:00     ` Kiryl Shutsemau (Meta) [this message]
2026-11-24 19:47 ` [PATCH 2/2] firmware: arm_sdei_nmi: Send the backtrace IPI to CPUs with SDEI masked Kiryl Shutsemau (Meta)
2026-11-25  9:51   ` YinFengwei
2026-11-25  2:21 ` [PATCH 0/2] firmware: arm_sdei: Fix NMI backtrace lockups on idle CPUs Jinjie Ruan

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=awblcOnI8JVhpmPK@shutemov.name \
    --to=kas@kernel.org \
    --cc=ada.coupriediaz@arm.com \
    --cc=ashok.raj@oss.qualcomm.com \
    --cc=catalin.marinas@arm.com \
    --cc=cwang@multikernel.io \
    --cc=dianders@chromium.org \
    --cc=fengwei_yin@linux.alibaba.com \
    --cc=james.morse@arm.com \
    --cc=kernel-team@meta.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=ruanjinjie@huawei.com \
    --cc=stable@vger.kernel.org \
    --cc=vladimir.murzin@arm.com \
    --cc=will@kernel.org \
    --cc=zhangpengjie2@huawei.com \
    /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

all inboxes | Powered by JetHome®