Skip to contentSkip to conversation

FAILED: patch "[PATCH] panic: flatten nmi_panic control flow" failed to apply to 6.12-stable tree

PATCH New Sasha Levin 1 participant 3 messages Nov 7 – Nov 10 Stable branch

lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 75eb687ff2bcec9fba31bbe266e5f91e5c283efe
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'

Thanks,
Sasha

------------------ original commit in Linus's tree ------------------

From 75eb687ff2bcec9fba31bbe266e5f91e5c283efe Mon Sep 17 00:00:00 2001
From: Bradley Morgan <[email protected]>
Date: Wed, 16 Sep 2026 18:29:53 +0000
Subject: [PATCH] panic: flatten nmi_panic control flow

panic() is __noreturn, so the else after panic_try_start() is dead. Drop it so the force_cpu path can be added cleanly on top.

---
 kernel/panic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/panic.c +2 -1
index 08072bfae4221..5646d4fb82b7d 100644
@@ -517,7 +517,8 @@ void nmi_panic(struct pt_regs *regs, const char *msg)
 {
 	if (panic_try_start())
 		panic("%s", msg);
-	else if (panic_on_other_cpu())
+
+	if (panic_on_other_cpu())
 		nmi_panic_self_stop(regs);
 }
 EXPORT_SYMBOL(nmi_panic);
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/2 panic: use panic_try_start() in nmi_panic()

From: Jinchao Wang <[email protected]>

[ Upstream commit 6b69c7ef96f1afc7b426195087f7488f1510c2a4 ]

nmi_panic() duplicated the logic to claim panic_cpu with atomic_try_cmpxchg. This is already wrapped in panic_try_start().

Replace the open-coded logic with panic_try_start(), and use panic_on_other_cpu() for the fallback path.

This removes duplication and keeps panic handling code consistent.

Cc Anna Schumaker <[email protected]>
Cc Baoquan He <[email protected]>
Cc "Darrick J. Wong" <[email protected]>
Cc Dave Young <[email protected]>
Cc Doug Anderson <[email protected]>
Cc "Guilherme G. Piccoli" <[email protected]>
Cc Helge Deller <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Joanthan Cameron <[email protected]>
Cc Joel Granados <[email protected]>
Cc John Ogness <[email protected]>
Cc Kees Cook <[email protected]>
Cc Li Huafei <[email protected]>
Cc "Luck, Tony" <[email protected]>
Cc Luo Gengkun <[email protected]>
Cc Max Kellermann <[email protected]>
Cc Nam Cao <[email protected]>
Cc oushixiong <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Qianqiang Liu <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
Cc Sohil Mehta <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Thomas Gleinxer <[email protected]>
Cc Thomas Zimemrmann <[email protected]>
Cc Thorsten Blum <[email protected]>
Cc Ville Syrjala <[email protected]>
Cc Vivek Goyal <[email protected]>
Cc Yicong Yang <[email protected]>
Cc Yunhui Cui <[email protected]>
Cc Yury Norov (NVIDIA) <[email protected]>

Stable-dep-of: 75eb687ff2bc ("panic: flatten nmi_panic control flow")

---
 kernel/panic.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
kernel/panic.c +2 -8
index 97c472164393b..b4db7f62b8ed5 100644
@@ -248,15 +248,9 @@ EXPORT_SYMBOL(panic_on_other_cpu);
  */
 void nmi_panic(struct pt_regs *regs, const char *msg)
 {
-	int old_cpu, this_cpu;
-
-	old_cpu = PANIC_CPU_INVALID;
-	this_cpu = raw_smp_processor_id();
-
-	/* atomic_try_cmpxchg updates old_cpu on failure */
-	if (atomic_try_cmpxchg(&panic_cpu, &old_cpu, this_cpu))
+	if (panic_try_start())
 		panic("%s", msg);
-	else if (old_cpu != this_cpu)
+	else if (panic_on_other_cpu())
 		nmi_panic_self_stop(regs);
 }
 EXPORT_SYMBOL(nmi_panic);
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH 2/2 panic: flatten nmi_panic control flow

From: Bradley Morgan <[email protected]>

[ Upstream commit 75eb687ff2bcec9fba31bbe266e5f91e5c283efe ]

panic() is __noreturn, so the else after panic_try_start() is dead. Drop it so the force_cpu path can be added cleanly on top.

---
 kernel/panic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/panic.c +2 -1
index b4db7f62b8ed5..16c21189c8da9 100644
@@ -250,7 +250,8 @@ void nmi_panic(struct pt_regs *regs, const char *msg)
 {
 	if (panic_try_start())
 		panic("%s", msg);
-	else if (panic_on_other_cpu())
+
+	if (panic_on_other_cpu())
 		nmi_panic_self_stop(regs);
 }
 EXPORT_SYMBOL(nmi_panic);
Signature · 1 line
2.53.0