Skip to contentSkip to conversation

Introduce arch_do_panic

PATCH Superseded Mete Durlu 5 participants 18 messages Jul 27 – Jul 29

Subsystems (2)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Mete Durlu

author
#0 lore raw

v2 cover Introduce arch_do_panic

Changes in v2 - Address Sashiko findings;
- Patch 2: Remove unused leftover code
- Patch 2: Mention panic_timeout and shutdown_actions relationship for s390 in commit message
- Patch 3: Use bug.h instead of setup.h to pass around arch_do_panic implementation of sparc

Replace architecture-specific ifdef sections in vpanic() with a clean arch_do_panic() hook. Currently s390 and sparc embed their panic handlers directly in vpanic() using preprocessor conditionals, making the common code path harder to maintain.

Introduce arch_do_panic() as an architecture extension point called at the end of vpanic(). Architectures can use this hook to implement their specific panic handling without polluting the generic panic code.

Move s390 panic handling from the panic_notifier chain to arch_do_panic(). This corrects the execution order so that the panic_timeout is properly evaluated before architecture-specific actions. The previous notifier-based approach executed too early in the panic sequence.

Move sparc panic handling from ifdef blocks to arch_do_panic(). Remove the preprocessor conditionals from vpanic() and place the Stop-A enablement code in architecture-specific files where it belongs.

The cleanup reduces vpanic() complexity and establishes a pattern for other architectures needing custom panic behavior.

---
Mete Durlu (3):
panic: Introduce arch_do_panic
s390: Implement arch_do_panic
sparc: Implement arch_do_panic

 arch/s390/include/asm/setup.h  |  3 +++
 arch/s390/kernel/ipl.c         | 15 +--------------
 arch/sparc/include/asm/bug.h   |  3 +++
 arch/sparc/include/asm/setup.h |  1 -
 arch/sparc/kernel/setup.c      |  8 ++++++++
 kernel/panic.c                 | 18 ++++++------------
 6 files changed, 21 insertions(+), 27 deletions(-)

---
base-commit: 48a5a7ab8d6ab7090564339e039c421f315de912
change-id: 20260724-arch_do_panic-a97f699aa332

Best regards,

Signature · 1 line
Mete Durlu <[email protected]>
author
#1 lore raw

PATCH v2 1/3 panic: Introduce arch_do_panic

Introduce a hook for architectures to put their specific panic handlers. s390 and sparc already has ifdef preprocessor checks to execute architecture specific code. Pave the way for vpanic() cleanup.

---
 kernel/panic.c | 6 ++++++
 1 file changed, 6 insertions(+)
kernel/panic.c +6 -0
index 213725b612aa..1eb0cdc159d9 100644
@@ -567,6 +567,11 @@ static void panic_other_cpus_shutdown(bool crash_kexec)
 		crash_smp_send_stop();
 }
 
+#ifndef arch_do_panic
+#define arch_do_panic arch_do_panic
+static inline void arch_do_panic(void) {}
+#endif
+
 /**
  * vpanic - halt the system
  * @fmt: The text string to print
@@ -756,6 +761,7 @@ void vpanic(const char *fmt, va_list args)
 #endif
 	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
 
+	arch_do_panic();
 	/* Do not scroll important messages printed above */
 	suppress_printk = 1;
 
Signature · 1 line
2.55.0
author
#5 lore raw

PATCH v2 2/3 s390: Implement arch_do_panic

In reply to Mete Durlu

s390 has a custom panic handler which carries out user specified actions during a panic scenario. This handler is invoked via the panic_notifier call chain and executed before panic_timeout value is evaluated in common code.

Use arch_do_panic() hook to invoke arch specific panic handling instead of using panic_notifier call chain. The execution order of panic handlers now allow for user specified panic_timeout value to be taken into account.

This now means that the panic_timeout value takes precedence over user defined on_panic behavior.

Fixes ff6b8ea68f4b ("[S390] ipl/dump on panic.")
---
 arch/s390/include/asm/setup.h |  3 +++
 arch/s390/kernel/ipl.c        | 15 +--------------
 kernel/panic.c                |  3 ---
 3 files changed, 4 insertions(+), 17 deletions(-)
arch/s390/include/asm/setup.h +3 -0
index cbf60ade741d..6b38017f7cf3 100644
@@ -90,6 +90,9 @@ extern void (*_machine_restart)(char *command);
 extern void (*_machine_halt)(void);
 extern void (*_machine_power_off)(void);
 
+void arch_do_panic(void);
+#define arch_do_panic arch_do_panic
+
 struct oldmem_data {
 	unsigned long start;
 	unsigned long size;
arch/s390/kernel/ipl.c +1 -14
index 3c346b02ceb9..8ab02e821256 100644
@@ -2115,7 +2115,7 @@ static ssize_t on_panic_store(struct kobject *kobj,
 }
 static struct kobj_attribute on_panic_attr = __ATTR_RW(on_panic);
 
-static void do_panic(void)
+void arch_do_panic(void)
 {
 	lgr_info_log();
 	on_panic_trigger.action->fn(&on_panic_trigger);
@@ -2331,18 +2331,6 @@ static int __init vmcmd_on_poff_setup(char *str)
 }
 __setup("vmpoff=", vmcmd_on_poff_setup);
 
-static int on_panic_notify(struct notifier_block *self,
-			   unsigned long event, void *data)
-{
-	do_panic();
-	return NOTIFY_OK;
-}
-
-static struct notifier_block on_panic_nb = {
-	.notifier_call = on_panic_notify,
-	.priority = INT_MIN,
-};
-
 void __init setup_ipl(void)
 {
 	BUILD_BUG_ON(sizeof(struct ipl_parameter_block) != PAGE_SIZE);
@@ -2375,7 +2363,6 @@ void __init setup_ipl(void)
 		/* We have no info to copy */
 		break;
 	}
-	atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb);
 }
 
 void __no_stack_protector s390_reset_system(void)
kernel/panic.c +0 -3
index 1eb0cdc159d9..de0bda946cab 100644
@@ -755,9 +755,6 @@ void vpanic(const char *fmt, va_list args)
 		pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
 			 "twice on console to return to the boot prom\n");
 	}
-#endif
-#if defined(CONFIG_S390)
-	disabled_wait();
 #endif
 	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
 
Signature · 1 line
2.55.0
author
#12 lore raw

PATCH v2 3/3 sparc: Implement arch_do_panic

In reply to Mete Durlu

Implement sparc specific arch_do_panic() instead of using sparc specific ifdef sections in vpanic() code.

---
 arch/sparc/include/asm/bug.h   | 3 +++
 arch/sparc/include/asm/setup.h | 1 -
 arch/sparc/kernel/setup.c      | 8 ++++++++
 kernel/panic.c                 | 9 ---------
 4 files changed, 11 insertions(+), 10 deletions(-)
arch/sparc/include/asm/bug.h +3 -0
index ea53e418f6c0..70dc3358430c 100644
@@ -27,4 +27,7 @@ void do_BUG(const char *file, int line);
 struct pt_regs;
 void __noreturn die_if_kernel(char *str, struct pt_regs *regs);
 
+void arch_do_panic(void);
+#define arch_do_panic arch_do_panic
+
 #endif
arch/sparc/include/asm/setup.h +0 -1
index 21bed5514028..fed37c85ed00 100644
@@ -43,7 +43,6 @@ void __init device_scan(void);
 
 /* unaligned_32.c */
 unsigned long safe_compute_effective_address(struct pt_regs *, unsigned int);
-
 #endif
 
 #ifdef CONFIG_SPARC64
arch/sparc/kernel/setup.c +8 -0
index 4975867d9001..87d3569c520f 100644
@@ -36,6 +36,14 @@ static const struct ctl_table sparc_sysctl_table[] = {
 #endif
 };
 
+void arch_do_panic(void)
+{
+	extern int stop_a_enabled;
+	/* Make sure the user can actually press Stop-A (L1-A) */
+	stop_a_enabled = 1;
+	pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
+		 "twice on console to return to the boot prom\n");
+}
 
 static int __init init_sparc_sysctls(void)
 {
kernel/panic.c +0 -9
index de0bda946cab..593aa2c24d93 100644
@@ -747,15 +747,6 @@ void vpanic(const char *fmt, va_list args)
 			reboot_mode = panic_reboot_mode;
 		emergency_restart();
 	}
-#ifdef __sparc__
-	{
-		extern int stop_a_enabled;
-		/* Make sure the user can actually press Stop-A (L1-A) */
-		stop_a_enabled = 1;
-		pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
-			 "twice on console to return to the boot prom\n");
-	}
-#endif
 	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
 
 	arch_do_panic();
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v2 1/3] panic: Introduce arch_do_panic

In reply to Mete Durlu
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines

Introduce a hook for architectures to put their specific panic handlers. s390 and sparc already has ifdef preprocessor checks to execute architecture specific code. Pave the way for vpanic() cleanup.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#13 lore raw

Re: [PATCH v2 3/3] sparc: Implement arch_do_panic

In reply to Mete Durlu
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] The function `arch_do_panic` is defined without a visible prototype, triggering a…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] The function arch_do_panic is defined without a visible prototype, triggering a -Wmissing-prototypes compiler warning.
- [Low] Redundant local extern declaration of stop_a_enabled.
--

--- Patch [3]: [PATCH v2 3/3] sparc: Implement arch_do_panic --- commit ab46dd14f9e80619721232e0fc090eea0709afa1
Author: Mete Durlu <[email protected]>

sparc: Implement arch_do_panic

Implement sparc specific arch_do_panic() instead of using sparc specific ifdef sections in vpanic() code.

Quoted 4 lines
arch/sparc/kernel/setup.c +0 -0
index 4975867d9001b..87d3569c520f8 100644

[ ... ]

arch/sparc/kernel/setup.c static const struct ctl_table sparc_sysctl_table[] = { · line 39

Quoted 5 lines
arch/sparc/kernel/setup.c +1 -0
@@ -36,6 +36,14 @@ static const struct ctl_table sparc_sysctl_table[] = {
 #endif
 };
 
+void arch_do_panic(void)

[Severity: Low]
Does this trigger a -Wmissing-prototypes compiler warning? The patch declares arch_do_panic() in arch/sparc/include/asm/bug.h, but fails to include that header (or linux/bug.h) here where the function is actually implemented.

While it might appear that asm/setup.h indirectly includes linux/bug.h via linux/interrupt.h -> linux/jump_label.h, the jump_label.h header only includes linux/bug.h if CONFIG_JUMP_LABEL is disabled. If enabled, the indirect inclusion path is broken. Could we add a direct include of linux/bug.h or asm/bug.h to ensure safety across all configurations?

arch/sparc/kernel/setup.c static const struct ctl_table sparc_sysctl_table[] = { · line 41

Quoted 2 lines
arch/sparc/kernel/setup.c +2 -0
+{
+	extern int stop_a_enabled;

[Severity: Low]
Is this local extern declaration still needed? Because arch/sparc/kernel/setup.c directly includes asm/setup.h at the top of the file, stop_a_enabled is already globally declared for all configurations.

Could we remove this redundant block-scope declaration that was leftover from when the code resided in kernel/panic.c?

Quoted 5 lines
arch/sparc/kernel/setup.c +5 -0
+	/* Make sure the user can actually press Stop-A (L1-A) */
+	stop_a_enabled = 1;
+	pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
+		 "twice on console to return to the boot prom\n");
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#6 lore raw

Re: [PATCH v2 2/3] s390: Implement arch_do_panic

In reply to Mete Durlu
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Moving the s390 on_panic trigger execution to arch_do_panic() causes it to be completely skipped…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Moving the s390 on_panic trigger execution to arch_do_panic() causes it to be completely skipped if a non-zero panic_timeout is configured, silently breaking hardware crash dumps. --

--- Patch [2]: [PATCH v2 2/3] s390: Implement arch_do_panic --- commit c54479b24863a9224f8701eeac5365ad207e8313
Author: Mete Durlu <[email protected]>

s390: Implement arch_do_panic

This commit moves the s390-specific panic handling out of the panic_notifier call chain and into the arch_do_panic hook. The stated intention is to allow the generic panic_timeout to take precedence over the architecture's user-defined panic behavior.

Quoted 3 lines
arch/s390/kernel/ipl.c +0 -0

[ ... ]

Quoted 11 lines
arch/s390/kernel/ipl.c +1 -1
@@ -2115,7 +2115,7 @@ static ssize_t on_panic_store(struct kobject *kobj,
 }
 static struct kobj_attribute on_panic_attr = __ATTR_RW(on_panic);
 
-static void do_panic(void)
+void arch_do_panic(void)
 {
 	lgr_info_log();
 	on_panic_trigger.action->fn(&on_panic_trigger);

stop_run(&on_panic_trigger);
}

[Severity: High]
If a non-zero panic_timeout is configured, vpanic calls emergency_restart which never returns.

Since arch_do_panic is invoked at the very end of vpanic after the timeout logic:

kernel/panic.c:vpanic() {
        ...
        if (panic_timeout != 0) {
                ...
                emergency_restart();
        }
        ...
        arch_do_panic();
        ...
}

Does this mean the s390 hardware dump logic here will be completely skipped instead of taking lower precedence? Could this regression silently break crash dumps configured via on_panic=dump when a generic timeout parameter is set?

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#3 lore raw

Re: [PATCH v2 1/3] panic: Introduce arch_do_panic

In reply to Mete Durlu

Hi Mete,

Review

Quoted 4 lines
(quoted diff) +4 -0
+#ifndef arch_do_panic
+#define arch_do_panic arch_do_panic
+static inline void arch_do_panic(void) {}
+#endif

this is fragile. the arch override only kicks in if whatever header defines the macro happens to be in panic.c's include chain. if it ever falls out, the empty stub wins silently, the arch version still compiles as a global nobody calls, and the hook is just dead. no build break, no warning, nothing.

use a weak function instead. arch defines the strong symbol and thats it, no macro dance, no header placement contract, and the silent stub failure cant happen. nobody cares about an indirect call in the panic path. something like:

include/linux/panic.h +1 -0
@@ -13,6 +13,7 @@ __printf(1, 2)
 void panic(const char *fmt, ...) __noreturn __cold;
 __printf(1, 0)
 void vpanic(const char *fmt, va_list args) __noreturn __cold;
+void arch_do_panic(void);
 void nmi_panic(struct pt_regs *regs, const char *msg);
 void check_panic_on_warn(const char *origin);
 extern void oops_enter(void);
kernel/panic.c +6 -0
@@ -567,6 +567,11 @@ static void panic_other_cpus_shutdown(bool crash_kexec)
 		crash_smp_send_stop();
 }
 
+/* Overridden by architectures with a panic handler of last resort. */
+void __weak arch_do_panic(void)
+{
+}
+
 /**
  * vpanic - halt the system
  * @fmt: The text string to print
@@ -756,6 +761,7 @@ void vpanic(const char *fmt, va_list args)
 #endif
 	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
 
+	arch_do_panic();
 	/* Do not scroll important messages printed above */
 	suppress_printk = 1;
 

untested, and no SoB from me, its a suggestion. if you fold it into v3 its your patch under your own SoB as usual.

(Heh, hope my client don't mutilate this)

the prototype in panic.h also means the arch definitions dont trip -Wmissing-prototypes, which your version dodges with the macro but only as long as the header keeps getting pulled in.

Review

Quoted 3 lines
	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
(quoted diff) +1 -0
+	arch_do_panic();

one more thing on the call site: arch code now runs (and prints, on sparc) after the "end Kernel panic" marker, which until now was the last line anyone would ever see. tools grep for that as a terminal marker. probably fine, but say so in the changelog instead of leaving it implicit.

s/already has/already have/ in the changelog while your at it.

Thanks!

#7 lore raw

Re: [PATCH v2 2/3] s390: Implement arch_do_panic

In reply to Mete Durlu

Mete,

Review

Quoted 4 lines
(quoted diff) +0 -4
-#endif
-#if defined(CONFIG_S390)
-	disabled_wait();
-#endif

removal is fine, this was unreachable anyway. the notifier ran do_panic() which ends in stop_run(), so nothing ever came back to hit this disabled_wait().

Review

Quoted 2 lines
(quoted diff) +2 -0
+void arch_do_panic(void);
+#define arch_do_panic arch_do_panic

with the weak function i suggested on patch 1, this whole asm/setup.h hunk disappears and the patch shrinks to exactly the parts that mean something:

arch/s390/kernel/ipl.c +1 -14
@@ -2115,7 +2115,7 @@ static ssize_t on_panic_store(struct kobject *kobj,
 }
 static struct kobj_attribute on_panic_attr = __ATTR_RW(on_panic);
 
-static void do_panic(void)
+void arch_do_panic(void)
 {
 	lgr_info_log();
 	on_panic_trigger.action->fn(&on_panic_trigger);
@@ -2331,18 +2331,6 @@ static int __init vmcmd_on_poff_setup(char *str)
 }
 __setup("vmpoff=", vmcmd_on_poff_setup);
 
-static int on_panic_notify(struct notifier_block *self,
-			   unsigned long event, void *data)
-{
-	do_panic();
-	return NOTIFY_OK;
-}
-
-static struct notifier_block on_panic_nb = {
-	.notifier_call = on_panic_notify,
-	.priority = INT_MIN,
-};
-
 void __init setup_ipl(void)
 {
 	BUILD_BUG_ON(sizeof(struct ipl_parameter_block) != PAGE_SIZE);
@@ -2375,7 +2363,6 @@ void __init setup_ipl(void)
 		/* We have no info to copy */
 		break;
 	}
-	atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb);
 }
 
 void __no_stack_protector s390_reset_system(void)
kernel/panic.c +0 -3
@@ -755,9 +755,6 @@ void vpanic(const char *fmt, va_list args)
 		pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
 			 "twice on console to return to the boot prom\n");
 	}
-#endif
-#if defined(CONFIG_S390)
-	disabled_wait();
 #endif
 	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
 

same deal, suggestion only, no SoB from me, fold it in under yours. check whether linux/panic_notifier.h is still needed in ipl.c after the notifier goes away.

Quoted 2 lines

This now means that the panic_timeout value takes precedence over user defined on_panic behavior.

this is the part i want to poke at. distros routinely ship panic=N on the cmdline. with this change, anyone who configured on_panic=dump on such a system silently stops getting dumps, because emergency_restart() runs first and never returns. a reboot instead of the dump you explicitly asked for is strictly worse. if you and Sven want that semantic, fine, but spell it out properly and give the s390 docs for on_panic a line about the new precedence.

also worth saying in the changelog what this actually wins: today the INT_MIN notifier never returns, so sys_info, kmsg_dump, the post notifier crash_kexec path, the console flushes and the end banner never execute on s390 once on_panic fires. after this patch they all do. thats the headline and the changelog undersells it.

Quoted 1 line
Fixes ff6b8ea68f4b ("[S390] ipl/dump on panic.")

What's broken? What's buggy? I'm sure this is just a behaviour change, could you either

1: Drop the fixes tag
2: Put in the changelog What's broken and why?

s/now allow/now allows/ in the changelog..
Thanks!

#14 lore raw

Re: [PATCH v2 3/3] sparc: Implement arch_do_panic

In reply to Mete Durlu

Hi Mete,

the move itself is right. with the weak function from patch 1 the asm/bug.h hunk goes away, and the asm/setup.h hunk deleting a blank line is unrelated churn that shouldnt be here either. what remains:

arch/sparc/kernel/setup.c +9 -0
@@ -36,6 +36,15 @@ static const struct ctl_table sparc_sysctl_table[] = {
 #endif
 };
 
+void arch_do_panic(void)
+{
+	extern int stop_a_enabled;
+
+	/* Make sure the user can actually press Stop-A (L1-A) */
+	stop_a_enabled = 1;
+	pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
+		 "twice on console to return to the boot prom\n");
+}
 
 static int __init init_sparc_sysctls(void)
 {
kernel/panic.c +0 -9
@@ -747,15 +747,6 @@ void vpanic(const char *fmt, va_list args)
 			reboot_mode = panic_reboot_mode;
 		emergency_restart();
 	}
-#ifdef __sparc__
-	{
-		extern int stop_a_enabled;
-		/* Make sure the user can actually press Stop-A (L1-A) */
-		stop_a_enabled = 1;
-		pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
-			 "twice on console to return to the boot prom\n");
-	}
-#endif
 	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
 
 	arch_do_panic();

suggestion only, no SoB from me, its yours to fold into v3.

note the Stop A message now prints after the "end Kernel panic" marker instead of before it. thats the call site from patch 1 doing that, im ok with it, but it wants a sentence in the changelog.

with the stray hunks gone this looks good to me.
Thanks!

author
#4 lore raw

Re: [PATCH v2 1/3] panic: Introduce arch_do_panic

In reply to Bradley Morgan
Quoted 1 line · Bradley Morgan

Hi Mete,

Hi Bradley,

Quoted 11 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+#ifndef arch_do_panic
+#define arch_do_panic arch_do_panic
+static inline void arch_do_panic(void) {}
+#endif

this is fragile. the arch override only kicks in if whatever header defines the macro happens to be in panic.c's include chain. if it ever falls out, the empty stub wins silently, the arch version still compiles as a global nobody calls, and the hook is just dead. no build break, no warning, nothing.

Quoted 1 line

use a weak function instead.

While I acknowledge the benefits you just listed, I got the notion that maintainers don't prefer __weak implementations and instead opt for arch specific override via ifndef guards. Therefore I wanted to start with this approach.

However I am willing to switch if the maintainers would favor that approach.

Quoted 6 lines

one more thing on the call site: arch code now runs (and prints, on sparc) after the "end Kernel panic" marker, which until now was the last line anyone would ever see. tools grep for that as a terminal marker. probably fine, but say so in the changelog instead of leaving it implicit.

Right, I'll mention that. And by changelog I take it that you mean the commit message, right?

Quoted 1 line

s/already has/already have/ in the changelog while your at it.

Thanks, I'll fix the typo in the next version.

author
#8 lore raw

Re: [PATCH v2 2/3] s390: Implement arch_do_panic

In reply to Bradley Morgan

On 27/07/2026 15:01, Bradley Morgan wrote:

Hi Bradley,

Quoted 10 lines
Quoted 2 lines

This now means that the panic_timeout value takes precedence over user defined on_panic behavior.

this is the part i want to poke at. distros routinely ship panic=N on the cmdline. with this change, anyone who configured on_panic=dump on such a system silently stops getting dumps, because emergency_restart() runs first and never returns. a reboot instead of the dump you explicitly asked for is strictly worse. if you and Sven want that semantic, fine, but spell it out properly and give the s390 docs for on_panic a line about the new precedence.

FWICT, there is no mention of shutdown actions in kernel documentation. s390's user documentation is a different story. I agree it should be documented on Linux on IBM systems documentation.

I'd argue that specifying both on_panic=dump and panic=N (N>0) is a configuration error, but maybe a pr_warn() could be added to the when on_panic=dump is configured with panic=N is set. That could hint what is wrong if anyone investigating dmesg and trying to figure out why system didn't dump.

On another note, dumping via shutdown actions serves as a backup and kdump is the main dump mechanism nowadays. Kdump always takes precedence over panic=N.

Quoted 6 lines

also worth saying in the changelog what this actually wins: today the INT_MIN notifier never returns, so sys_info, kmsg_dump, the post notifier crash_kexec path, the console flushes and the end banner never execute on s390 once on_panic fires. after this patch they all do. thats the headline and the changelog undersells it.

Right, I will add that part to the commit message too.

Quoted 3 lines
Quoted 1 line
Fixes ff6b8ea68f4b ("[S390] ipl/dump on panic.")

What's broken? What's buggy?

I can put a couple of sentences on how and why panic= kernel command line argument was broken for s390.

Quoted 1 line

s/now allow/now allows/ in the changelog..

Will fix in next version!

Thank you

#9 lore raw

Re: [PATCH v2 2/3] s390: Implement arch_do_panic

Quoted 19 lines · Mete Durlu

On 27/07/2026 15:01, Bradley Morgan wrote:

Hi Bradley,

Quoted 10 lines
Quoted 2 lines

This now means that the panic_timeout value takes precedence over user defined on_panic behavior.

this is the part i want to poke at. distros routinely ship panic=N on the cmdline. with this change, anyone who configured on_panic=dump on such a system silently stops getting dumps, because emergency_restart() runs first and never returns. a reboot instead of the dump you explicitly asked for is strictly worse. if you and Sven want that semantic, fine, but spell it out properly and give the s390 docs for on_panic a line about the new precedence.

FWICT, there is no mention of shutdown actions in kernel documentation. s390's user documentation is a different story. I agree it should be documented on Linux on IBM systems documentation.

Quoted 6 lines

I'd argue that specifying both on_panic=dump and panic=N (N>0) is a configuration error, but maybe a pr_warn() could be added to the when on_panic=dump is configured with panic=N is set. That could hint what is wrong if anyone investigating dmesg and trying to figure out why system didn't dump.

hey, sorry I'm out, so I can't do the most massive think ever, and I may embarrass myself, heh.

I think a BUG would be sufficient, we would want to shut down the system with said bug, I know about panic on warn, but sometimes that's not always enabled, something like a BUG would be good, what do you think?

Quoted 17 lines

On another note, dumping via shutdown actions serves as a backup and kdump is the main dump mechanism nowadays. Kdump always takes precedence over panic=N.

Quoted 6 lines

also worth saying in the changelog what this actually wins: today the INT_MIN notifier never returns, so sys_info, kmsg_dump, the post notifier crash_kexec path, the console flushes and the end banner never execute on s390 once on_panic fires. after this patch they all do. thats the headline and the changelog undersells it.

Right, I will add that part to the commit message too.

Quoted 3 lines
Quoted 1 line
Fixes ff6b8ea68f4b ("[S390] ipl/dump on panic.")

What's broken? What's buggy?

Quoted 9 lines

I can put a couple of sentences on how and why panic= kernel command line argument was broken for s390.

Quoted 1 line

s/now allow/now allows/ in the changelog..

Will fix in next version!

Thank you

Thanks!

reviewer
#10 lore raw

Re: [PATCH v2 2/3] s390: Implement arch_do_panic

Quoted 28 lines · Bradley Morgan
Quoted 19 lines · Mete Durlu

On 27/07/2026 15:01, Bradley Morgan wrote:

Hi Bradley,

Quoted 10 lines
Quoted 2 lines

This now means that the panic_timeout value takes precedence over user defined on_panic behavior.

this is the part i want to poke at. distros routinely ship panic=N on the cmdline. with this change, anyone who configured on_panic=dump on such a system silently stops getting dumps, because emergency_restart() runs first and never returns. a reboot instead of the dump you explicitly asked for is strictly worse. if you and Sven want that semantic, fine, but spell it out properly and give the s390 docs for on_panic a line about the new precedence.

FWICT, there is no mention of shutdown actions in kernel documentation. s390's user documentation is a different story. I agree it should be documented on Linux on IBM systems documentation.

Quoted 6 lines

I'd argue that specifying both on_panic=dump and panic=N (N>0) is a configuration error, but maybe a pr_warn() could be added to the when on_panic=dump is configured with panic=N is set. That could hint what is wrong if anyone investigating dmesg and trying to figure out why system didn't dump.

Quoted 6 lines

hey, sorry I'm out, so I can't do the most massive think ever, and I may embarrass myself, heh.

I think a BUG would be sufficient, we would want to shut down the system with said bug, I know about panic on warn, but sometimes that's not always enabled, something like a BUG would be good, what do you think?

Err... No. You don't want to make a mistake while updating the kernel panic parameters just to figure out that on the next boot the kernel just BUGs() because of that. There are of course lots of reasons why changing the kernel command line could end up in a non-bootable system but this one would be ridiculous.

#11 lore raw

Re: [PATCH v2 2/3] s390: Implement arch_do_panic

Quoted 39 lines · Sven Schnelle
Quoted 6 lines · Bradley Morgan
Quoted 5 lines · Mete Durlu

On 27/07/2026 15:01, Bradley Morgan wrote:

Hi Bradley,

Quoted 1 line
Quoted 1 line

This now means that the panic_timeout value takes precedence over

user

Quoted 22 lines
Quoted 14 lines
Quoted 9 lines
Quoted 1 line

defined on_panic behavior.

this is the part i want to poke at. distros routinely ship panic=N on the cmdline. with this change, anyone who configured on_panic=dump on such a system silently stops getting dumps, because emergency_restart() runs first and never returns. a reboot instead of the dump you explicitly asked for is strictly worse. if you and Sven want that semantic, fine, but spell it out properly and give the s390 docs for on_panic a line about the new precedence.

FWICT, there is no mention of shutdown actions in kernel documentation. s390's user documentation is a different story. I agree it should be documented on Linux on IBM systems documentation.

Quoted 6 lines

I'd argue that specifying both on_panic=dump and panic=N (N>0) is a configuration error, but maybe a pr_warn() could be added to the when on_panic=dump is configured with panic=N is set. That could hint what is wrong if anyone investigating dmesg and trying to figure out why system didn't dump.

Quoted 5 lines

hey, sorry I'm out, so I can't do the most massive think ever, and I may embarrass myself, heh.

I think a BUG would be sufficient, we would want to shut down the system with said bug, I know about panic on warn, but sometimes that's not

always

Quoted 1 line

enabled, something like a BUG would be good, what do you think?

Quoted 8 lines

Err... No. You don't want to make a mistake while updating the kernel panic parameters just to figure out that on the next boot the kernel just BUGs()
because of that. There are of course lots of reasons why changing the kernel
command line could end up in a non-bootable system but this one would be ridiculous.

hey, yes, fair enough , thanks, I never said the warn was objectively wrong, (fair enough), it was more a question.

Thanks!

maintainer
#15 lore raw
In reply to Mete Durlu
Quoted 36 lines · Mete Durlu

Changes in v2 - Address Sashiko findings;
- Patch 2: Remove unused leftover code
- Patch 2: Mention panic_timeout and shutdown_actions relationship for s390 in commit message
- Patch 3: Use bug.h instead of setup.h to pass around arch_do_panic implementation of sparc

Replace architecture-specific ifdef sections in vpanic() with a clean arch_do_panic() hook. Currently s390 and sparc embed their panic handlers directly in vpanic() using preprocessor conditionals, making the common code path harder to maintain.

Introduce arch_do_panic() as an architecture extension point called at the end of vpanic(). Architectures can use this hook to implement their specific panic handling without polluting the generic panic code.

Move s390 panic handling from the panic_notifier chain to arch_do_panic(). This corrects the execution order so that the panic_timeout is properly evaluated before architecture-specific actions. The previous notifier-based approach executed too early in the panic sequence.

Move sparc panic handling from ifdef blocks to arch_do_panic(). Remove the preprocessor conditionals from vpanic() and place the Stop-A enablement code in architecture-specific files where it belongs.

The cleanup reduces vpanic() complexity and establishes a pattern for other architectures needing custom panic behavior.

---
Mete Durlu (3):
panic: Introduce arch_do_panic
s390: Implement arch_do_panic
sparc: Implement arch_do_panic

Quoted 7 lines
 arch/s390/include/asm/setup.h  |  3 +++
 arch/s390/kernel/ipl.c         | 15 +--------------
 arch/sparc/include/asm/bug.h   |  3 +++
 arch/sparc/include/asm/setup.h |  1 -
 arch/sparc/kernel/setup.c      |  8 ++++++++
 kernel/panic.c                 | 18 ++++++------------
 6 files changed, 21 insertions(+), 27 deletions(-)

Putting the define in a different header file per architecture doesn't seem to be a good idea. There is no guarantee that this will work. So either you find a common header file, where it is known that is (and will be) included in panic.c, or you go with a weak function.

author
#16 lore raw
Quoted 45 lines · Heiko Carstens
Quoted 36 lines · Mete Durlu

Changes in v2 - Address Sashiko findings;
- Patch 2: Remove unused leftover code
- Patch 2: Mention panic_timeout and shutdown_actions relationship for s390 in commit message
- Patch 3: Use bug.h instead of setup.h to pass around arch_do_panic implementation of sparc

Replace architecture-specific ifdef sections in vpanic() with a clean arch_do_panic() hook. Currently s390 and sparc embed their panic handlers directly in vpanic() using preprocessor conditionals, making the common code path harder to maintain.

Introduce arch_do_panic() as an architecture extension point called at the end of vpanic(). Architectures can use this hook to implement their specific panic handling without polluting the generic panic code.

Move s390 panic handling from the panic_notifier chain to arch_do_panic(). This corrects the execution order so that the panic_timeout is properly evaluated before architecture-specific actions. The previous notifier-based approach executed too early in the panic sequence.

Move sparc panic handling from ifdef blocks to arch_do_panic(). Remove the preprocessor conditionals from vpanic() and place the Stop-A enablement code in architecture-specific files where it belongs.

The cleanup reduces vpanic() complexity and establishes a pattern for other architectures needing custom panic behavior.

---
Mete Durlu (3):
panic: Introduce arch_do_panic
s390: Implement arch_do_panic
sparc: Implement arch_do_panic

Quoted 7 lines
  arch/s390/include/asm/setup.h  |  3 +++
  arch/s390/kernel/ipl.c         | 15 +--------------
  arch/sparc/include/asm/bug.h   |  3 +++
  arch/sparc/include/asm/setup.h |  1 -
  arch/sparc/kernel/setup.c      |  8 ++++++++
  kernel/panic.c                 | 18 ++++++------------
  6 files changed, 21 insertions(+), 27 deletions(-)
Quoted 4 lines

Putting the define in a different header file per architecture doesn't seem to be a good idea. There is no guarantee that this will work. So either you find a common header file, where it is known that is (and will be) included in panic.c, or you go with a weak function.

I went over the headers included to panic.c, either they are really irrelevant or not present on other archs. To me the best candidate header seems like "asm/bug.h"

$ find ./arch/ -name "bug.h" | grep include/asm | wc -l
16
$ ls ./arch | wc -l
22 # actually 21 as we shouldn't count Kconfig file

The architectures missing bug.h in their include/asm/ directory are hexagon, microblaze, nios2, um and xtensa

I believe 16/21 is a good ratio but if this is still not good enough, I'd like to fallback to __weak implementation.

What do you think Heiko?

maintainer
#17 lore raw
Quoted 17 lines · Mete Durlu
Quoted 5 lines · Heiko Carstens

On Mon, Jul 27, 2026 at 12:36:19PM +0200, Mete Durlu wrote:
Putting the define in a different header file per architecture doesn't seem to be a good idea. There is no guarantee that this will work. So either you find a common header file, where it is known that is (and will be) included in panic.c, or you go with a weak function.

I went over the headers included to panic.c, either they are really irrelevant or not present on other archs. To me the best candidate header seems like "asm/bug.h"

$ find ./arch/ -name "bug.h" | grep include/asm | wc -l
16
$ ls ./arch | wc -l
22 # actually 21 as we shouldn't count Kconfig file
Quoted 7 lines

The architectures missing bug.h in their include/asm/ directory are hexagon, microblaze, nios2, um and xtensa

I believe 16/21 is a good ratio but if this is still not good enough, I'd like to fallback to __weak implementation.

What do you think Heiko?

Then go for __weak and wait if people shout at you :)