The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] panic: make force_cpu redirect work from an NMI
@ 2026-07-07 20:59 Bradley Morgan
  2026-07-08 12:44 ` Petr Mladek
  0 siblings, 1 reply; 2+ messages in thread
From: Bradley Morgan @ 2026-07-07 20:59 UTC (permalink / raw)
  To: akpm; +Cc: pmladek, feng.tang, linux-kernel, include

nmi_panic sets panic_cpu first. Bail only on a different
owner, and hand panic_cpu to the target after the IPI.

Found by sashiko [1].

[1] https://sashiko.dev/#/patchset/20260707183253.9793-1-include@grrlz.net

Signed-off-by: Bradley Morgan <include@grrlz.net>
---
 kernel/panic.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index e46c37b39c40..95ebf2bb0bf9 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -396,8 +396,8 @@ static bool panic_try_force_cpu(const char *fmt, va_list args)
 		return false;
 	}
 
-	/* Another panic already in progress */
-	if (panic_in_progress())
+	/* Bail only if a different CPU is already handling it. */
+	if (panic_in_progress() && atomic_read(&panic_cpu) != this_cpu)
 		return false;
 
 	/* Which CPU won the race? */
@@ -440,6 +440,9 @@ static bool panic_try_force_cpu(const char *fmt, va_list args)
 		return false;
 	}
 
+	/* Hand panic_cpu to the target so it wins its own panic_try_start. */
+	atomic_set(&panic_cpu, panic_force_cpu);
+
 	/* IPI/NMI sent, this CPU should stop */
 	return true;
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-08 12:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 20:59 [PATCH] panic: make force_cpu redirect work from an NMI Bradley Morgan
2026-07-08 12:44 ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox