* [PATCH v2 1/4] sys_info: add helper for callers that handle all_bt
@ 2026-06-23 15:34 Bradley Morgan
2026-06-23 15:34 ` [PATCH v2 2/4] watchdog: avoid sys_info fallback for all_bt Bradley Morgan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Bradley Morgan @ 2026-06-23 15:34 UTC (permalink / raw)
To: Petr Mladek, Feng Tang, Andrew Morton
Cc: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Mukesh Kumar Chaurasiya, Andy Shevchenko,
Jinchao Wang, Kees Cook, Rio, Joel Granados, Pnina Feder,
Petr Pavlu, Sergey Senozhatsky, Douglas Anderson, Mayank Rungta,
Tejun Heo, Zhenguo Yao, linuxppc-dev, linux-kernel, stable,
Bradley Morgan
Some callers handle SYS_INFO_ALL_BT themselves before calling sys_info().
Add a helper that strips that bit without turning an all_bt only mask into
a kernel_sys_info fallback.
Signed-off-by: Bradley Morgan <include@grrlz.net>
---
Changes since v1:
- New patch for the shared helper suggested by Petr.
include/linux/sys_info.h | 1 +
lib/sys_info.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/linux/sys_info.h b/include/linux/sys_info.h
index a5bc3ea3d44b..87a841ec7b6a 100644
--- a/include/linux/sys_info.h
+++ b/include/linux/sys_info.h
@@ -18,6 +18,7 @@
#define SYS_INFO_BLOCKED_TASKS 0x00000080
void sys_info(unsigned long si_mask);
+void sys_info_without_all_bt(unsigned long si_mask);
unsigned long sys_info_parse_param(char *str);
#ifdef CONFIG_SYSCTL
diff --git a/lib/sys_info.c b/lib/sys_info.c
index f32a06ec9ed4..6afd4c697633 100644
--- a/lib/sys_info.c
+++ b/lib/sys_info.c
@@ -164,3 +164,18 @@ void sys_info(unsigned long si_mask)
{
__sys_info(si_mask ? : kernel_si_mask);
}
+
+void sys_info_without_all_bt(unsigned long si_mask)
+{
+ unsigned long dump_mask = si_mask & ~SYS_INFO_ALL_BT;
+
+ /*
+ * Do not call sys_info() when the caller context required only
+ * backtraces from all CPUs. Otherwise sys_info() would fall back
+ * to the generic kernel_si_mask.
+ */
+ if (si_mask && !dump_mask)
+ return;
+
+ sys_info(dump_mask);
+}
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/4] watchdog: avoid sys_info fallback for all_bt
2026-06-23 15:34 [PATCH v2 1/4] sys_info: add helper for callers that handle all_bt Bradley Morgan
@ 2026-06-23 15:34 ` Bradley Morgan
2026-06-23 15:35 ` [PATCH v2 3/4] powerpc/watchdog: " Bradley Morgan
2026-06-23 15:35 ` [PATCH v2 4/4] panic: avoid duplicate all CPU backtraces from sys_info Bradley Morgan
2 siblings, 0 replies; 4+ messages in thread
From: Bradley Morgan @ 2026-06-23 15:34 UTC (permalink / raw)
To: Petr Mladek, Feng Tang, Andrew Morton
Cc: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Mukesh Kumar Chaurasiya, Andy Shevchenko,
Jinchao Wang, Kees Cook, Rio, Joel Granados, Pnina Feder,
Petr Pavlu, Sergey Senozhatsky, Douglas Anderson, Mayank Rungta,
Tejun Heo, Zhenguo Yao, linuxppc-dev, linux-kernel, stable,
Bradley Morgan
The watchdog prints all CPU backtraces itself. When the watchdog mask
contains only SYS_INFO_ALL_BT, stripping that bit leaves zero and
sys_info(0) falls back to kernel_sys_info.
Use sys_info_without_all_bt() so an explicit all_bt mask does not request
the global default.
Fixes: a9af76a78760 ("watchdog: add sys_info sysctls to dump sys info on system lockup")
Cc: stable@vger.kernel.org
Signed-off-by: Bradley Morgan <include@grrlz.net>
---
Changes since v1:
- Use the shared sys_info_without_all_bt() helper.
- Keep the generic watchdog change separate from powerpc.
kernel/watchdog.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 87dd5e0f6968..5bf24231a5d8 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -208,6 +208,7 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
{
int hardlockup_all_cpu_backtrace;
unsigned int this_cpu;
+ unsigned long si_mask;
unsigned long flags;
if (per_cpu(watchdog_hardlockup_touched, cpu)) {
@@ -216,7 +217,8 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
return;
}
- hardlockup_all_cpu_backtrace = (hardlockup_si_mask & SYS_INFO_ALL_BT) ?
+ si_mask = READ_ONCE(hardlockup_si_mask);
+ hardlockup_all_cpu_backtrace = (si_mask & SYS_INFO_ALL_BT) ?
1 : sysctl_hardlockup_all_cpu_backtrace;
/*
* Check for a hardlockup by making sure the CPU's timer
@@ -286,7 +288,7 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
clear_bit_unlock(0, &hard_lockup_nmi_warn);
}
- sys_info(hardlockup_si_mask & ~SYS_INFO_ALL_BT);
+ sys_info_without_all_bt(si_mask);
if (hardlockup_panic)
nmi_panic(regs, "Hard LOCKUP");
@@ -798,6 +800,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
struct pt_regs *regs = get_irq_regs();
int softlockup_all_cpu_backtrace;
int duration, thresh_count;
+ unsigned long si_mask;
unsigned long flags;
if (!watchdog_enabled)
@@ -809,7 +812,8 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
if (panic_in_progress())
return HRTIMER_NORESTART;
- softlockup_all_cpu_backtrace = (softlockup_si_mask & SYS_INFO_ALL_BT) ?
+ si_mask = READ_ONCE(softlockup_si_mask);
+ softlockup_all_cpu_backtrace = (si_mask & SYS_INFO_ALL_BT) ?
1 : sysctl_softlockup_all_cpu_backtrace;
watchdog_hardlockup_kick();
@@ -900,7 +904,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
}
add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK);
- sys_info(softlockup_si_mask & ~SYS_INFO_ALL_BT);
+ sys_info_without_all_bt(si_mask);
thresh_count = duration / get_softlockup_thresh();
if (softlockup_panic && thresh_count >= softlockup_panic)
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/4] powerpc/watchdog: avoid sys_info fallback for all_bt
2026-06-23 15:34 [PATCH v2 1/4] sys_info: add helper for callers that handle all_bt Bradley Morgan
2026-06-23 15:34 ` [PATCH v2 2/4] watchdog: avoid sys_info fallback for all_bt Bradley Morgan
@ 2026-06-23 15:35 ` Bradley Morgan
2026-06-23 15:35 ` [PATCH v2 4/4] panic: avoid duplicate all CPU backtraces from sys_info Bradley Morgan
2 siblings, 0 replies; 4+ messages in thread
From: Bradley Morgan @ 2026-06-23 15:35 UTC (permalink / raw)
To: Petr Mladek, Feng Tang, Andrew Morton
Cc: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Mukesh Kumar Chaurasiya, Andy Shevchenko,
Jinchao Wang, Kees Cook, Rio, Joel Granados, Pnina Feder,
Petr Pavlu, Sergey Senozhatsky, Douglas Anderson, Mayank Rungta,
Tejun Heo, Zhenguo Yao, linuxppc-dev, linux-kernel, stable,
Bradley Morgan
The powerpc watchdog prints all CPU backtraces itself. When the watchdog
mask contains only SYS_INFO_ALL_BT, stripping that bit leaves zero and
sys_info(0) falls back to kernel_sys_info.
Use sys_info_without_all_bt() so an explicit all_bt mask does not request
the global default.
Fixes: e561383a39ed ("powerpc/watchdog: add support for hardlockup_sys_info sysctl")
Cc: stable@vger.kernel.org
Signed-off-by: Bradley Morgan <include@grrlz.net>
---
Changes since v1:
- Use the shared sys_info_without_all_bt() helper.
- Keep the powerpc watchdog change in its own patch.
arch/powerpc/kernel/watchdog.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
index c40c69368476..813f9d48a6be 100644
--- a/arch/powerpc/kernel/watchdog.c
+++ b/arch/powerpc/kernel/watchdog.c
@@ -201,6 +201,7 @@ static bool set_cpu_stuck(int cpu)
static void watchdog_smp_panic(int cpu)
{
static cpumask_t wd_smp_cpus_ipi; // protected by reporting
+ unsigned long si_mask;
unsigned long flags;
u64 tb, last_reset;
int c;
@@ -236,8 +237,9 @@ static void watchdog_smp_panic(int cpu)
pr_emerg("CPU %d TB:%lld, last SMP heartbeat TB:%lld (%lldms ago)\n",
cpu, tb, last_reset, tb_to_ns(tb - last_reset) / 1000000);
+ si_mask = READ_ONCE(hardlockup_si_mask);
if (sysctl_hardlockup_all_cpu_backtrace ||
- (hardlockup_si_mask & SYS_INFO_ALL_BT)) {
+ (si_mask & SYS_INFO_ALL_BT)) {
trigger_allbutcpu_cpu_backtrace(cpu);
cpumask_clear(&wd_smp_cpus_ipi);
} else {
@@ -251,7 +253,7 @@ static void watchdog_smp_panic(int cpu)
}
}
- sys_info(hardlockup_si_mask & ~SYS_INFO_ALL_BT);
+ sys_info_without_all_bt(si_mask);
if (hardlockup_panic)
nmi_panic(NULL, "Hard LOCKUP");
@@ -371,6 +373,7 @@ static void watchdog_timer_interrupt(int cpu)
DEFINE_INTERRUPT_HANDLER_NMI(soft_nmi_interrupt)
{
+ unsigned long si_mask;
unsigned long flags;
int cpu = raw_smp_processor_id();
u64 tb;
@@ -418,11 +421,12 @@ DEFINE_INTERRUPT_HANDLER_NMI(soft_nmi_interrupt)
xchg(&__wd_nmi_output, 1); // see wd_lockup_ipi
+ si_mask = READ_ONCE(hardlockup_si_mask);
if (sysctl_hardlockup_all_cpu_backtrace ||
- (hardlockup_si_mask & SYS_INFO_ALL_BT))
+ (si_mask & SYS_INFO_ALL_BT))
trigger_allbutcpu_cpu_backtrace(cpu);
- sys_info(hardlockup_si_mask & ~SYS_INFO_ALL_BT);
+ sys_info_without_all_bt(si_mask);
if (hardlockup_panic)
nmi_panic(regs, "Hard LOCKUP");
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 4/4] panic: avoid duplicate all CPU backtraces from sys_info
2026-06-23 15:34 [PATCH v2 1/4] sys_info: add helper for callers that handle all_bt Bradley Morgan
2026-06-23 15:34 ` [PATCH v2 2/4] watchdog: avoid sys_info fallback for all_bt Bradley Morgan
2026-06-23 15:35 ` [PATCH v2 3/4] powerpc/watchdog: " Bradley Morgan
@ 2026-06-23 15:35 ` Bradley Morgan
2 siblings, 0 replies; 4+ messages in thread
From: Bradley Morgan @ 2026-06-23 15:35 UTC (permalink / raw)
To: Petr Mladek, Feng Tang, Andrew Morton
Cc: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Mukesh Kumar Chaurasiya, Andy Shevchenko,
Jinchao Wang, Kees Cook, Rio, Joel Granados, Pnina Feder,
Petr Pavlu, Sergey Senozhatsky, Douglas Anderson, Mayank Rungta,
Tejun Heo, Zhenguo Yao, linuxppc-dev, linux-kernel, stable,
Bradley Morgan
panic_other_cpus_shutdown() handles SYS_INFO_ALL_BT before stopping the
other CPUs. Do not ask sys_info() to handle that bit again later in the
panic path.
Use sys_info_without_all_bt() so panic_print=all_bt does not request more
output after the CPUs are stopped.
Fixes: b76e89e50fc3 ("panic: generalize panic_print's function to show sys info")
Cc: stable@vger.kernel.org
Signed-off-by: Bradley Morgan <include@grrlz.net>
---
Changes since v1:
- New patch using the same helper for panic.
kernel/panic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/panic.c b/kernel/panic.c
index d030f88ad4ef..2cf229c7c0cf 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -683,7 +683,7 @@ void vpanic(const char *fmt, va_list args)
*/
atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
- sys_info(panic_print);
+ sys_info_without_all_bt(panic_print);
kmsg_dump_desc(KMSG_DUMP_PANIC, buf);
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-23 15:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 15:34 [PATCH v2 1/4] sys_info: add helper for callers that handle all_bt Bradley Morgan
2026-06-23 15:34 ` [PATCH v2 2/4] watchdog: avoid sys_info fallback for all_bt Bradley Morgan
2026-06-23 15:35 ` [PATCH v2 3/4] powerpc/watchdog: " Bradley Morgan
2026-06-23 15:35 ` [PATCH v2 4/4] panic: avoid duplicate all CPU backtraces from sys_info Bradley Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox