Skip to content

Commit 160c7ba

Browse files
committed
lib: Add backtrace_idle parameter to force backtrace of idle CPUs
Currently, the nmi_cpu_backtrace() declines to produce backtraces for idle CPUs. This is a good choice in the common case in which problems are caused only by non-idle CPUs. However, there are occasionally situations in which idle CPUs are helping to cause problems. This commit therefore adds an nmi_backtrace.backtrace_idle kernel boot parameter that causes nmi_cpu_backtrace() to dump stacks even of idle CPUs. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: <linux-doc@vger.kernel.org>
1 parent 9123e3a commit 160c7ba

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,6 +3073,10 @@
30733073
and gids from such clients. This is intended to ease
30743074
migration from NFSv2/v3.
30753075

3076+
nmi_backtrace.backtrace_idle [KNL]
3077+
Dump stacks even of idle CPUs in response to an
3078+
NMI stack-backtrace request.
3079+
30763080
nmi_debug= [KNL,SH] Specify one or more actions to take
30773081
when a NMI is triggered.
30783082
Format: [state][,regs][,debounce][,die]

lib/nmi_backtrace.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
8585
put_cpu();
8686
}
8787

88+
// Dump stacks even for idle CPUs.
89+
static bool backtrace_idle;
90+
module_param(backtrace_idle, bool, 0644);
91+
8892
bool nmi_cpu_backtrace(struct pt_regs *regs)
8993
{
9094
int cpu = smp_processor_id();
9195

9296
if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
93-
if (regs && cpu_in_idle(instruction_pointer(regs))) {
97+
if (!READ_ONCE(backtrace_idle) && regs && cpu_in_idle(instruction_pointer(regs))) {
9498
pr_warn("NMI backtrace for cpu %d skipped: idling at %pS\n",
9599
cpu, (void *)instruction_pointer(regs));
96100
} else {

0 commit comments

Comments
 (0)