Linux Watchdog driver development
 help / color / mirror / Atom feed
From: Mayank Rungta via B4 Relay <devnull+mrungta.google.com@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	 Wim Van Sebroeck <wim@linux-watchdog.org>,
	 Guenter Roeck <linux@roeck-us.net>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>,
	 Douglas Anderson <dianders@chromium.org>,
	linux-kernel@vger.kernel.org,  linux-watchdog@vger.kernel.org,
	Mayank Rungta <mrungta@google.com>
Subject: [PATCH 1/2] nmi: Export CPU backtrace APIs for loadable modules
Date: Thu, 30 Jul 2026 15:00:21 -0700	[thread overview]
Message-ID: <20260730-export-cpu-backtrace-apis-v1-1-bace8e1cb817@google.com> (raw)
In-Reply-To: <20260730-export-cpu-backtrace-apis-v1-0-bace8e1cb817@google.com>

From: Mayank Rungta <mrungta@google.com>

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.

Signed-off-by: Mayank Rungta <mrungta@google.com>
---
 include/linux/nmi.h | 10 ++++++----
 lib/nmi_backtrace.c |  7 +++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index 89c5465e2524..af69712df5f4 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -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;
 }
 
diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c
index a3bfa9360b23..f39c9eca8888 100644
--- a/lib/nmi_backtrace.c
+++ b/lib/nmi_backtrace.c
@@ -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

-- 
2.55.0.508.g3f0d502094-goog



  reply	other threads:[~2026-07-30 22:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 22:00 [PATCH 0/2] watchdog: pretimeout: Allow building dump governor as module Mayank Rungta via B4 Relay
2026-07-30 22:00 ` Mayank Rungta via B4 Relay [this message]
2026-07-31  1:54   ` [PATCH 1/2] nmi: Export CPU backtrace APIs for loadable modules Doug Anderson
2026-08-06 21:40   ` Guenter Roeck
2026-08-06 23:44   ` Andrew Morton
2026-08-07  3:50   ` Guenter Roeck
2026-07-30 22:00 ` [PATCH 2/2] watchdog: pretimeout: Convert dump pretimeout governor to tristate Mayank Rungta via B4 Relay
2026-07-31  1:55   ` Doug Anderson
2026-08-01 12:38   ` Tzung-Bi Shih
2026-08-06 21:41   ` Guenter Roeck
2026-08-06 23:44   ` Andrew Morton
2026-08-07  3:50   ` Guenter Roeck
2026-07-30 22:50 ` [PATCH 0/2] watchdog: pretimeout: Allow building dump governor as module Andrew Morton
2026-07-30 23:39   ` Mayank Rungta
2026-07-31 21:01     ` Andrew Morton
2026-07-31 21:19       ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260730-export-cpu-backtrace-apis-v1-1-bace8e1cb817@google.com \
    --to=devnull+mrungta.google.com@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dianders@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mrungta@google.com \
    --cc=tzungbi@kernel.org \
    --cc=wim@linux-watchdog.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox