Skip to contentSkip to conversation

panic-introduce-helper-functions-for-panic-state.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Sep 14, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: panic: introduce helper functions for panic state
has been removed from the -mm tree. Its filename was
panic-introduce-helper-functions-for-panic-state.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Jinchao Wang <[email protected]>
Subject: panic: introduce helper functions for panic state
Date: Mon, 25 Aug 2025 10:29:29 +0800

Patch series "panic: introduce panic status function family", v2.

This series introduces a family of helper functions to manage panic state and updates existing code to use them.

Before this series, panic state helpers were scattered and inconsistent. For example, panic_in_progress() was defined in printk/printk.c, not in panic.c or panic.h. As a result, developers had to look in unexpected places to understand or re-use panic state logic. Other checks were open- coded, duplicating logic across panic, crash, and watchdog paths.

The new helpers centralize the functionality in panic.c/panic.h:
- panic_try_start()
- panic_reset()
- panic_in_progress()
- panic_on_this_cpu()
- panic_on_other_cpu()

Patches 1–8 add the helpers and convert panic/crash and printk/nbcon code to use them.

Patch 9 fixes a bug in the watchdog subsystem by skipping checks when a panic is in progress, avoiding interference with the panic CPU.

Together, this makes panic state handling simpler, more discoverable, and more robust.

This patch (of 9):

This patch introduces four new helper functions to abstract the management of the panic_cpu variable. These functions will be used in subsequent patches to refactor existing code.

The direct use of panic_cpu can be error-prone and ambiguous, as it requires manual checks to determine which CPU is handling the panic. The new helpers clarify intent:

panic_try_start():
Atomically sets the current CPU as the panicking CPU.

panic_reset():
Reset panic_cpu to PANIC_CPU_INVALID.

panic_in_progress():
Checks if a panic has been triggered.

panic_on_this_cpu():
Returns true if the current CPU is the panic originator.

panic_on_other_cpu():
Returns true if a panic is on another CPU.

This change lays the groundwork for improved code readability and robustness in the panic handling subsystem.

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]>b

---

 include/linux/panic.h  |    6 ++++
 kernel/panic.c         |   53 +++++++++++++++++++++++++++++++++++++++
 kernel/printk/printk.c |    5 ---
 3 files changed, 59 insertions(+), 5 deletions(-)
include/linux/panic.h renamed from include/linux/panic.h~panic-introduce-helper-functions-for-panic-state +6 -0
@@ -43,6 +43,12 @@ void abort(void);
 extern atomic_t panic_cpu;
 #define PANIC_CPU_INVALID	-1
 
+bool panic_try_start(void);
+void panic_reset(void);
+bool panic_in_progress(void);
+bool panic_on_this_cpu(void);
+bool panic_on_other_cpu(void);
+
 /*
  * Only to be used by arch init code. If the user over-wrote the default
  * CONFIG_PANIC_TIMEOUT, honor it.
kernel/panic.c renamed from kernel/panic.c~panic-introduce-helper-functions-for-panic-state +53 -0

59 lines not on this page · raw message

kernel/printk/printk.c renamed from kernel/printk/printk.c~panic-introduce-helper-functions-for-panic-state +0 -5
@@ -345,11 +345,6 @@ static void __up_console_sem(unsigned lo
 }
 #define up_console_sem() __up_console_sem(_RET_IP_)
 
-static bool panic_in_progress(void)
-{
-	return unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID);
-}
-
 /* Return true if a panic is in progress on the current CPU. */
 bool this_cpu_in_panic(void)
 {

_

Patches currently in -mm which might be from [email protected] are