* [PATCH v6 0/3] Introduce arch_do_panic
@ 2026-08-31 9:57 Mete Durlu
2026-08-31 9:57 ` [PATCH v6 1/3] panic: " Mete Durlu
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Mete Durlu @ 2026-08-31 9:57 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
David S. Miller, Andreas Larsson, Bradley Morgan
Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu
Changes in v6:
- Collect Reviewed-by's and Acked-by's (Bradley Morgan, Heiko Carstens)
- Rebase to 7.3
Changes in v5:
- Move s390 arch_do_panic() implementation to a more suitable
file (Heiko Carstens)
Changes in v4:
- Remove s390 specific behavior changes and limit the series with
cosmetic clean ups and introduction of arch_do_panic()
(Heiko Carstens)
- Include linux/panic.h on files where arch_do_panic() is implemented
(Sashiko)
- Remove extern "stop_a_enabled" definition from sparc's arch_do_panic()
implementation as it is already visible by included asm/setup.h
(Sashiko)
- Include "linux/printk.h" header on sparc/setup.c explicitly for
pr_emerg() (Sashiko)
Changes in v3:
- Use __weak functions instead of symbol override via ifdef
- Patch 2: Better explain what is fixed (Bradley Morgan)
- Add statements about print order changes (Bradley Morgan)
- Patch 2: Add a pr_warn() to notify user about on_panic and
panic_timeout relationship if they try to assign a trigger to
on_panic action while panic_timeout is set to a value other than 0
(Bradley Morgan)
A note before coverletter:
On earlier versions [1] I attempted to move s390s panic handler into
arch_do_panic() but the interaction between panic handler and kernel's
panic_timeout had become implicit and suboptimal. After reading Heiko's
comments I have decided to tackle that in a separate series and keep
this one limited to a smaller set of changes.
-------
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.
Remove s390s ifdef block in vpanic() and move the corresponding code
block to s390s own arch_do_panic() implementation in architecture
specific code.
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.
Stop-A enablement markers are now printed after "end Kernel panic"
line. To me, there are no better alternatives other than setup.c to
put sparc's arch_do_panic() implementation. The other files under
arch/sparc/kernel are either divided to *_32.c and *_64.c variants,
which mean code duplication, or unrelated.
The cleanup reduces vpanic() complexity and establishes a pattern for other
architectures needing custom panic behavior.
No functional changes, only minor print order changes.
[1] https://lore.kernel.org/all/20260730-arch_do_panic-v3-0-d5401e683cdb@linux.ibm.com/
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
Mete Durlu (3):
panic: Introduce arch_do_panic
s390: Implement arch_do_panic
sparc: Implement arch_do_panic
arch/s390/kernel/traps.c | 7 +++++++
arch/sparc/kernel/setup.c | 9 +++++++++
include/linux/panic.h | 2 ++
kernel/panic.c | 15 +++------------
4 files changed, 21 insertions(+), 12 deletions(-)
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260724-arch_do_panic-a97f699aa332
Best regards,
--
Mete Durlu <meted@linux.ibm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v6 1/3] panic: Introduce arch_do_panic
2026-08-31 9:57 [PATCH v6 0/3] Introduce arch_do_panic Mete Durlu
@ 2026-08-31 9:57 ` Mete Durlu
2026-08-31 10:07 ` sashiko-bot
2026-08-31 9:57 ` [PATCH v6 2/3] s390: Implement arch_do_panic Mete Durlu
2026-08-31 9:57 ` [PATCH v6 3/3] sparc: " Mete Durlu
2 siblings, 1 reply; 7+ messages in thread
From: Mete Durlu @ 2026-08-31 9:57 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
David S. Miller, Andreas Larsson, Bradley Morgan
Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu
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.
Reviewed-by: Bradley Morgan <include@grrlz.net>
Suggested-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
include/linux/panic.h | 2 ++
kernel/panic.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/include/linux/panic.h b/include/linux/panic.h
index f1dd417e54b2..98dd7dfd27de 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -110,4 +110,6 @@ extern void add_taint(unsigned flag, enum lockdep_ok);
extern int test_taint(unsigned flag);
extern unsigned long get_taint(void);
+void arch_do_panic(void);
+
#endif /* _LINUX_PANIC_H */
diff --git a/kernel/panic.c b/kernel/panic.c
index 213725b612aa..726a97842232 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -567,6 +567,8 @@ static void panic_other_cpus_shutdown(bool crash_kexec)
crash_smp_send_stop();
}
+void __weak arch_do_panic(void) {}
+
/**
* vpanic - halt the system
* @fmt: The text string to print
@@ -756,6 +758,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;
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v6 2/3] s390: Implement arch_do_panic
2026-08-31 9:57 [PATCH v6 0/3] Introduce arch_do_panic Mete Durlu
2026-08-31 9:57 ` [PATCH v6 1/3] panic: " Mete Durlu
@ 2026-08-31 9:57 ` Mete Durlu
2026-08-31 10:14 ` sashiko-bot
2026-08-31 9:57 ` [PATCH v6 3/3] sparc: " Mete Durlu
2 siblings, 1 reply; 7+ messages in thread
From: Mete Durlu @ 2026-08-31 9:57 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
David S. Miller, Andreas Larsson, Bradley Morgan
Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu
Implement s390 specific arch_do_panic() instead of using s390 specific
ifdef sections in vpanic() code. disabled_wait() is now called after
"end Kernel panic" marker.
No functional changes.
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Bradley Morgan <include@grrlz.net>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
arch/s390/kernel/traps.c | 7 +++++++
kernel/panic.c | 3 ---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index b6ba4465f59d..115cb3373247 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -26,6 +26,7 @@
#include <linux/entry-common.h>
#include <linux/kmsan.h>
#include <linux/bug.h>
+#include <linux/panic.h>
#include <asm/entry-percpu.h>
#include <asm/asm-extable.h>
#include <asm/irqflags.h>
@@ -33,6 +34,7 @@
#include <asm/vtime.h>
#include <asm/fpu.h>
#include <asm/fault.h>
+#include <asm/processor.h>
#include "entry.h"
struct pgm_stat {
@@ -283,6 +285,11 @@ static void monitor_event_exception(struct pt_regs *regs)
}
}
+void arch_do_panic(void)
+{
+ disabled_wait();
+}
+
void kernel_stack_invalid(struct pt_regs *regs)
{
/*
diff --git a/kernel/panic.c b/kernel/panic.c
index 726a97842232..ee6e3f9e3900 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -752,9 +752,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);
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v6 3/3] sparc: Implement arch_do_panic
2026-08-31 9:57 [PATCH v6 0/3] Introduce arch_do_panic Mete Durlu
2026-08-31 9:57 ` [PATCH v6 1/3] panic: " Mete Durlu
2026-08-31 9:57 ` [PATCH v6 2/3] s390: Implement arch_do_panic Mete Durlu
@ 2026-08-31 9:57 ` Mete Durlu
2026-08-31 10:21 ` sashiko-bot
2 siblings, 1 reply; 7+ messages in thread
From: Mete Durlu @ 2026-08-31 9:57 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
David S. Miller, Andreas Larsson, Bradley Morgan
Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu
Implement sparc specific arch_do_panic() instead of using sparc specific
ifdef sections in vpanic() code.
Reorder arch specific panic handling, sparc's Stop-A messages are now
printed after "end Kernel panic" marker.
Reviewed-by: Bradley Morgan <include@grrlz.net>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
arch/sparc/kernel/setup.c | 9 +++++++++
kernel/panic.c | 9 ---------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index 4975867d9001..5f43cef80638 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -2,6 +2,8 @@
#include <asm/setup.h>
#include <linux/sysctl.h>
+#include <linux/panic.h>
+#include <linux/printk.h>
static const struct ctl_table sparc_sysctl_table[] = {
{
@@ -36,6 +38,13 @@ static const struct ctl_table sparc_sysctl_table[] = {
#endif
};
+void arch_do_panic(void)
+{
+ /* 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)
{
diff --git a/kernel/panic.c b/kernel/panic.c
index ee6e3f9e3900..7dda841c16f9 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -744,15 +744,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();
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v6 1/3] panic: Introduce arch_do_panic
2026-08-31 9:57 ` [PATCH v6 1/3] panic: " Mete Durlu
@ 2026-08-31 10:07 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-08-31 10:07 UTC (permalink / raw)
To: Mete Durlu
Cc: Vasily Gorbik, Alexander Gordeev, linux-s390, Heiko Carstens,
Christian Borntraeger
> 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.
>
> Reviewed-by: Bradley Morgan <include@grrlz.net>
> Suggested-by: Sven Schnelle <svens@linux.ibm.com>
> Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831-arch_do_panic-v6-0-a1e170a9e7fd@linux.ibm.com?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v6 2/3] s390: Implement arch_do_panic
2026-08-31 9:57 ` [PATCH v6 2/3] s390: Implement arch_do_panic Mete Durlu
@ 2026-08-31 10:14 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-08-31 10:14 UTC (permalink / raw)
To: Mete Durlu
Cc: Christian Borntraeger, Vasily Gorbik, linux-s390, Heiko Carstens,
Alexander Gordeev
> Implement s390 specific arch_do_panic() instead of using s390 specific
> ifdef sections in vpanic() code. disabled_wait() is now called after
> "end Kernel panic" marker.
> No functional changes.
>
> Acked-by: Heiko Carstens <hca@linux.ibm.com>
> Reviewed-by: Bradley Morgan <include@grrlz.net>
> Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831-arch_do_panic-v6-0-a1e170a9e7fd@linux.ibm.com?part=2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v6 3/3] sparc: Implement arch_do_panic
2026-08-31 9:57 ` [PATCH v6 3/3] sparc: " Mete Durlu
@ 2026-08-31 10:21 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-08-31 10:21 UTC (permalink / raw)
To: Mete Durlu
Cc: Christian Borntraeger, Vasily Gorbik, linux-s390,
Alexander Gordeev, Heiko Carstens
> Implement sparc specific arch_do_panic() instead of using sparc specific
> ifdef sections in vpanic() code.
> Reorder arch specific panic handling, sparc's Stop-A messages are now
> printed after "end Kernel panic" marker.
>
> Reviewed-by: Bradley Morgan <include@grrlz.net>
> Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831-arch_do_panic-v6-0-a1e170a9e7fd@linux.ibm.com?part=3
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-31 10:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31 9:57 [PATCH v6 0/3] Introduce arch_do_panic Mete Durlu
2026-08-31 9:57 ` [PATCH v6 1/3] panic: " Mete Durlu
2026-08-31 10:07 ` sashiko-bot
2026-08-31 9:57 ` [PATCH v6 2/3] s390: Implement arch_do_panic Mete Durlu
2026-08-31 10:14 ` sashiko-bot
2026-08-31 9:57 ` [PATCH v6 3/3] sparc: " Mete Durlu
2026-08-31 10:21 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox