Skip to contentSkip to conversation

watchdog: pretimeout: Allow building dump governor as module

PATCH Applied Mayank Rungta 5 participants 16 messages Jul 30 – Aug 7

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover watchdog: pretimeout: Allow building dump governor as module

All other watchdog pretimeout governors (noop, panic) can be built as loadable modules. However the "dump" pretimeout governor is restricted to built-in code because it calls trigger_all_cpu_backtrace(), which relies on arch_trigger_cpumask_backtrace(), an arch specific helper that is not exported to loadable modules.

This 2-patch series allows building the dump governor as a module (=m):
1) Export cpumask_backtrace() in lib/nmi_backtrace.c.
2) Convert CONFIG_WATCHDOG_PRETIMEOUT_GOV_DUMP from bool to tristate.

---
Mayank Rungta (2):
nmi: Export CPU backtrace APIs for loadable modules
watchdog: pretimeout: Convert dump pretimeout governor to tristate

 drivers/watchdog/Kconfig |  4 ++--
 include/linux/nmi.h      | 10 ++++++----
 lib/nmi_backtrace.c      |  7 +++++++
 3 files changed, 15 insertions(+), 6 deletions(-)

---
base-commit: 3fe08b9796f36ef437ab9328e7dd1e5ff2d66603
change-id: 20260728-export-cpu-backtrace-apis-136d3b819377

Best regards,

Signature · 1 line
Mayank Rungta <[email protected]>
#1 lore raw

PATCH 1/2 nmi: Export CPU backtrace APIs for loadable modules

Currently, CPU backtrace functions cannot be called from loadable modules because the underlying helper arch_trigger_cpumask_backtrace() is not exported.

Instead of exporting arch_trigger_cpumask_backtrace() individually across every supported architecture, introduce and export a common helper, cpumask_backtrace(), in lib/nmi_backtrace.c. Update the four inline CPU backtrace macros in include/linux/nmi.h to route through this centralized helper.

---
 include/linux/nmi.h | 10 ++++++----
 lib/nmi_backtrace.c |  7 +++++++
 2 files changed, 13 insertions(+), 4 deletions(-)
include/linux/nmi.h +6 -4
index 89c5465e2524..af69712df5f4 100644
@@ -157,27 +157,29 @@ static inline void touch_nmi_watchdog(void)
  * to allow calling code to fall back to some other mechanism:
  */
 #ifdef arch_trigger_cpumask_backtrace
+void cpumask_backtrace(const cpumask_t *mask, int exclude_cpu);
+
 static inline bool trigger_all_cpu_backtrace(void)
 {
-	arch_trigger_cpumask_backtrace(cpu_online_mask, -1);
+	cpumask_backtrace(cpu_online_mask, -1);
 	return true;
 }
 
 static inline bool trigger_allbutcpu_cpu_backtrace(int exclude_cpu)
 {
-	arch_trigger_cpumask_backtrace(cpu_online_mask, exclude_cpu);
+	cpumask_backtrace(cpu_online_mask, exclude_cpu);
 	return true;
 }
 
 static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
 {
-	arch_trigger_cpumask_backtrace(mask, -1);
+	cpumask_backtrace(mask, -1);
 	return true;
 }
 
 static inline bool trigger_single_cpu_backtrace(int cpu)
 {
-	arch_trigger_cpumask_backtrace(cpumask_of(cpu), -1);
+	cpumask_backtrace(cpumask_of(cpu), -1);
 	return true;
 }
 
lib/nmi_backtrace.c +7 -0
index a3bfa9360b23..f39c9eca8888 100644
@@ -19,6 +19,7 @@
 #include <linux/stringify.h>
 #include <linux/nmi.h>
 #include <linux/cpu.h>
+#include <linux/export.h>
 #include <linux/sched/debug.h>
 
 #ifdef arch_trigger_cpumask_backtrace
@@ -129,4 +130,10 @@ bool nmi_cpu_backtrace(struct pt_regs *regs)
 	return false;
 }
 NOKPROBE_SYMBOL(nmi_cpu_backtrace);
+
+void cpumask_backtrace(const cpumask_t *mask, int exclude_cpu)
+{
+	arch_trigger_cpumask_backtrace(mask, exclude_cpu);
+}
+EXPORT_SYMBOL_GPL(cpumask_backtrace);
 #endif
Signature · 1 line
2.55.0.508.g3f0d502094-goog
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] nmi: Export CPU backtrace APIs for loadable modules

Hi,

Quoted 13 lines · On Thu, Jul 30, 2026 at 3:00 PM Mayank Rungta via B4 Relay…

From: Mayank Rungta <[email protected]>

Currently, CPU backtrace functions cannot be called from loadable modules because the underlying helper arch_trigger_cpumask_backtrace() is not exported.

Instead of exporting arch_trigger_cpumask_backtrace() individually across every supported architecture, introduce and export a common helper, cpumask_backtrace(), in lib/nmi_backtrace.c. Update the four inline CPU backtrace macros in include/linux/nmi.h to route through this centralized helper.

Quoted 5 lines
---
 include/linux/nmi.h | 10 ++++++----
 lib/nmi_backtrace.c |  7 +++++++
 2 files changed, 13 insertions(+), 4 deletions(-)
maintainer
#3 lore raw

Re: [PATCH 1/2] nmi: Export CPU backtrace APIs for loadable modules

In reply to Mayank Rungta
Quoted 6 lines · Mayank Rungta

From: Mayank Rungta <[email protected]>

Currently, CPU backtrace functions cannot be called from loadable modules because the underlying helper arch_trigger_cpumask_backtrace() is not exported.

Quoted 8 lines

Instead of exporting arch_trigger_cpumask_backtrace() individually across every supported architecture, introduce and export a common helper, cpumask_backtrace(), in lib/nmi_backtrace.c. Update the four inline CPU backtrace macros in include/linux/nmi.h to route through this centralized helper.

Just to give an update: I'd love to apply this and the next patch of the series, but I can not do wo without formal Ack from a maintainer (I did that once and got burned for it, so it won't happen again).

I'll send an Ack to the next patch of the series, in case someone else wants to pick it up.

Guenter

maintainer Reviewed-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] nmi: Export CPU backtrace APIs for loadable modules

In reply to Mayank Rungta
Quoted 11 lines · On Thu, 30 Jul 2026 15:00:21 -0700 Mayank Rungta via B4 Relay…

From: Mayank Rungta <[email protected]>

Currently, CPU backtrace functions cannot be called from loadable modules because the underlying helper arch_trigger_cpumask_backtrace() is not exported.

Instead of exporting arch_trigger_cpumask_backtrace() individually across every supported architecture, introduce and export a common helper, cpumask_backtrace(), in lib/nmi_backtrace.c. Update the four inline CPU backtrace macros in include/linux/nmi.h to route through this centralized helper.

maintainer Applied
#5 lore raw

Re: [PATCH 1/2] nmi: Export CPU backtrace APIs for loadable modules

In reply to Mayank Rungta
Quoted 12 lines · Mayank Rungta

From: Mayank Rungta <[email protected]>

Currently, CPU backtrace functions cannot be called from loadable modules because the underlying helper arch_trigger_cpumask_backtrace() is not exported.

Instead of exporting arch_trigger_cpumask_backtrace() individually across every supported architecture, introduce and export a common helper, cpumask_backtrace(), in lib/nmi_backtrace.c. Update the four inline CPU backtrace macros in include/linux/nmi.h to route through this centralized helper.

Quoted 3 lines

Applied.

Thanks,
Guenter

#6 lore raw

PATCH 2/2 watchdog: pretimeout: Convert dump pretimeout governor to tristate

In reply to Mayank Rungta

Commit 645ad41da8b2 ("watchdog: pretimeout: Add "dump" pretimeout governor") added the "dump" watchdog pretimeout governor, but restricted it to built-in code because trigger_all_cpu_backtrace() was not exported to loadable modules.

Now that CPU backtrace APIs are supported for loadable kernel modules via cpumask_backtrace(), convert WATCHDOG_PRETIMEOUT_GOV_DUMP to tristate. This allows kernels to deliver the pretimeout governor as a loadable kernel module.

---
 drivers/watchdog/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/Kconfig +2 -2
index 9f013d774897..922741dd837c 100644
@@ -99,8 +99,8 @@ config WATCHDOG_PRETIMEOUT_GOV_SEL
 if WATCHDOG_PRETIMEOUT_GOV
 
 config WATCHDOG_PRETIMEOUT_GOV_DUMP
-	bool "Dump watchdog pretimeout governor"
-	depends on WATCHDOG_CORE=y
+	tristate "Dump watchdog pretimeout governor"
+	depends on WATCHDOG_CORE
 	default WATCHDOG_CORE
 	help
 	  Dump watchdog pretimeout governor, all cpu backtrace is
Signature · 1 line
2.55.0.508.g3f0d502094-goog
Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] watchdog: pretimeout: Convert dump pretimeout governor to tristate

Hi,

Quoted 13 lines · On Thu, Jul 30, 2026 at 3:00 PM Mayank Rungta via B4 Relay…

From: Mayank Rungta <[email protected]>

Commit 645ad41da8b2 ("watchdog: pretimeout: Add "dump" pretimeout governor") added the "dump" watchdog pretimeout governor, but restricted it to built-in code because trigger_all_cpu_backtrace() was not exported to loadable modules.

Now that CPU backtrace APIs are supported for loadable kernel modules via cpumask_backtrace(), convert WATCHDOG_PRETIMEOUT_GOV_DUMP to tristate. This allows kernels to deliver the pretimeout governor as a loadable kernel module.

Quoted 4 lines
---
 drivers/watchdog/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by on v1 2/2
#8 lore raw

Re: [PATCH 2/2] watchdog: pretimeout: Convert dump pretimeout governor to tristate

In reply to Mayank Rungta
Quoted 3 lines · On Thu, Jul 30, 2026 at 03:00:22PM -0700, Mayank Rungta via B4 Relay wrote:

From: Mayank Rungta <[email protected]>

Commit 645ad41da8b2 ("watchdog: pretimeout: Add "dump" pretimeout

FWIW: The hash might have changed due to a rebase.

Quoted 10 lines

governor") added the "dump" watchdog pretimeout governor, but restricted it to built-in code because trigger_all_cpu_backtrace() was not exported to loadable modules.

Now that CPU backtrace APIs are supported for loadable kernel modules via cpumask_backtrace(), convert WATCHDOG_PRETIMEOUT_GOV_DUMP to tristate. This allows kernels to deliver the pretimeout governor as a loadable kernel module.

maintainer Acked-by on v1 2/2
#9 lore raw

Re: [PATCH 2/2] watchdog: pretimeout: Convert dump pretimeout governor to tristate

In reply to Mayank Rungta
Quoted 7 lines · Mayank Rungta

From: Mayank Rungta <[email protected]>

Commit 645ad41da8b2 ("watchdog: pretimeout: Add "dump" pretimeout governor") added the "dump" watchdog pretimeout governor, but restricted it to built-in code because trigger_all_cpu_backtrace() was not exported to loadable modules.

Quoted 8 lines

Now that CPU backtrace APIs are supported for loadable kernel modules via cpumask_backtrace(), convert WATCHDOG_PRETIMEOUT_GOV_DUMP to tristate. This allows kernels to deliver the pretimeout governor as a loadable kernel module.

As mentioned in the other patch, I can not apply the series without Ack from a maintainer. In case someone else wants to pick it up instead:

Quoted 19 lines
---
 drivers/watchdog/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/Kconfig +2 -2
index 9f013d774897..922741dd837c 100644
@@ -99,8 +99,8 @@ config WATCHDOG_PRETIMEOUT_GOV_SEL
 if WATCHDOG_PRETIMEOUT_GOV
 
 config WATCHDOG_PRETIMEOUT_GOV_DUMP
-	bool "Dump watchdog pretimeout governor"
-	depends on WATCHDOG_CORE=y
+	tristate "Dump watchdog pretimeout governor"
+	depends on WATCHDOG_CORE
 	default WATCHDOG_CORE
 	help
 	  Dump watchdog pretimeout governor, all cpu backtrace is
maintainer Reviewed-by on v1 2/2
#10 lore raw

Re: [PATCH 2/2] watchdog: pretimeout: Convert dump pretimeout governor to tristate

In reply to Mayank Rungta
Quoted 9 lines · On Thu, 30 Jul 2026 15:00:22 -0700 Mayank Rungta via B4 Relay…

Commit 645ad41da8b2 ("watchdog: pretimeout: Add "dump" pretimeout governor") added the "dump" watchdog pretimeout governor, but restricted it to built-in code because trigger_all_cpu_backtrace() was not exported to loadable modules.

Now that CPU backtrace APIs are supported for loadable kernel modules via cpumask_backtrace(), convert WATCHDOG_PRETIMEOUT_GOV_DUMP to tristate. This allows kernels to deliver the pretimeout governor as a loadable kernel module.

maintainer Applied
#11 lore raw

Re: [PATCH 2/2] watchdog: pretimeout: Convert dump pretimeout governor to tristate

In reply to Mayank Rungta
Quoted 12 lines · Mayank Rungta

From: Mayank Rungta <[email protected]>

Commit 645ad41da8b2 ("watchdog: pretimeout: Add "dump" pretimeout governor") added the "dump" watchdog pretimeout governor, but restricted it to built-in code because trigger_all_cpu_backtrace() was not exported to loadable modules.

Now that CPU backtrace APIs are supported for loadable kernel modules via cpumask_backtrace(), convert WATCHDOG_PRETIMEOUT_GOV_DUMP to tristate. This allows kernels to deliver the pretimeout governor as a loadable kernel module.

Quoted 5 lines

Applied.

Thanks,
Guenter

maintainer
#12 lore raw
In reply to Mayank Rungta
Quoted 9 lines · On Thu, 30 Jul 2026 15:00:20 -0700 Mayank Rungta via B4 Relay…

All other watchdog pretimeout governors (noop, panic) can be built as loadable modules. However the "dump" pretimeout governor is restricted to built-in code because it calls trigger_all_cpu_backtrace(), which relies on arch_trigger_cpumask_backtrace(), an arch specific helper that is not exported to loadable modules.

This 2-patch series allows building the dump governor as a module (=m):
1) Export cpumask_backtrace() in lib/nmi_backtrace.c.
2) Convert CONFIG_WATCHDOG_PRETIMEOUT_GOV_DUMP from bool to tristate.

LGTM. Can you please redo against current mainline? The Kconfig has changed.

#13 lore raw
Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Thu, 30 Jul 2026 15:00:20 -0700 Mayank Rungta via B4 Relay…

All other watchdog pretimeout governors (noop, panic) can be built as loadable modules. However the "dump" pretimeout governor is restricted to built-in code because it calls trigger_all_cpu_backtrace(), which relies on arch_trigger_cpumask_backtrace(), an arch specific helper that is not exported to loadable modules.

Quoted 7 lines
Quoted 3 lines

This 2-patch series allows building the dump governor as a module (=m):
1) Export cpumask_backtrace() in lib/nmi_backtrace.c.
2) Convert CONFIG_WATCHDOG_PRETIMEOUT_GOV_DUMP from bool to tristate.

LGTM. Can you please redo against current mainline? The Kconfig has changed.

Thanks for the LGTM!

Regarding rebasing onto mainline (origin/master): The "dump" pretimeout governor was added recently by Tzung-Bi Shih ("watchdog:
pretimeout: Add "dump" pretimeout governor") and is currently in linux-next, so it hasn't landed in mainline tree yet.

Because of this dependency, I based this series on linux-next so that patch 2/2 ("Convert dump pretimeout governor to tristate") could apply cleanly on top of the new governor.

Please let me know what is preferred, or if you'd like me to post against a different tree!

Thanks,
Mayank

maintainer
#14 lore raw
Quoted 25 lines · On Thu, 30 Jul 2026 16:39:14 -0700 Mayank Rungta <[email protected]> wrote:
Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Thu, 30 Jul 2026 15:00:20 -0700 Mayank Rungta via B4 Relay…

All other watchdog pretimeout governors (noop, panic) can be built as loadable modules. However the "dump" pretimeout governor is restricted to built-in code because it calls trigger_all_cpu_backtrace(), which relies on arch_trigger_cpumask_backtrace(), an arch specific helper that is not exported to loadable modules.

Quoted 7 lines
Quoted 3 lines

This 2-patch series allows building the dump governor as a module (=m):
1) Export cpumask_backtrace() in lib/nmi_backtrace.c.
2) Convert CONFIG_WATCHDOG_PRETIMEOUT_GOV_DUMP from bool to tristate.

LGTM. Can you please redo against current mainline? The Kconfig has changed.

Thanks for the LGTM!

Regarding rebasing onto mainline (origin/master): The "dump" pretimeout governor was added recently by Tzung-Bi Shih ("watchdog:
pretimeout: Add "dump" pretimeout governor") and is currently in linux-next, so it hasn't landed in mainline tree yet.

Quoted 7 lines

Because of this dependency, I based this series on linux-next so that patch 2/2 ("Convert dump pretimeout governor to tristate") could apply cleanly on top of the new governor.

Please let me know what is preferred, or if you'd like me to post against a different tree!

Oh, OK.

Guenter, can you please process this patchset?

maintainer
#15 lore raw
Quoted 31 lines · Andrew Morton
Quoted 29 lines · On Thu, 30 Jul 2026 16:39:14 -0700 Mayank Rungta <[email protected]> wrote:
Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Thu, 30 Jul 2026 15:00:20 -0700 Mayank Rungta via B4 Relay…

All other watchdog pretimeout governors (noop, panic) can be built as loadable modules. However the "dump" pretimeout governor is restricted to built-in code because it calls trigger_all_cpu_backtrace(), which relies on arch_trigger_cpumask_backtrace(), an arch specific helper that is not exported to loadable modules.

Quoted 7 lines
Quoted 3 lines

This 2-patch series allows building the dump governor as a module (=m):
1) Export cpumask_backtrace() in lib/nmi_backtrace.c.
2) Convert CONFIG_WATCHDOG_PRETIMEOUT_GOV_DUMP from bool to tristate.

LGTM. Can you please redo against current mainline? The Kconfig has changed.

Thanks for the LGTM!

Regarding rebasing onto mainline (origin/master): The "dump" pretimeout governor was added recently by Tzung-Bi Shih ("watchdog:
pretimeout: Add "dump" pretimeout governor") and is currently in linux-next, so it hasn't landed in mainline tree yet.

Because of this dependency, I based this series on linux-next so that patch 2/2 ("Convert dump pretimeout governor to tristate") could apply cleanly on top of the new governor.

Quoted 8 lines
Quoted 3 lines

Please let me know what is preferred, or if you'd like me to post against a different tree!

Oh, OK.

Guenter, can you please process this patchset?

Sure. Assuming you'd like me to handle it through the watchdog branch, it would be great if you can send a formal Acked-by: to the first patch of the series.

Thanks,
Guenter