Skip to content

Commit 55d6af1

Browse files
jognesspmladek
authored andcommitted
lib/nmi_backtrace: explicitly serialize banner and regs
Currently the nmi_backtrace is serialized against other CPUs because the messages are sent to the NMI buffers. Once these buffers are removed, only the dumped stack will be serialized against other CPUs (via the printk_cpu_lock). Also serialize the nmi_backtrace banner and regs using the printk_cpu_lock so that per-CPU serialization will be preserved even after the NMI buffers are removed. Signed-off-by: John Ogness <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 65090f3 commit 55d6af1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/nmi_backtrace.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,24 @@ module_param(backtrace_idle, bool, 0644);
9292
bool nmi_cpu_backtrace(struct pt_regs *regs)
9393
{
9494
int cpu = smp_processor_id();
95+
unsigned long flags;
9596

9697
if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
9798
if (!READ_ONCE(backtrace_idle) && regs && cpu_in_idle(instruction_pointer(regs))) {
9899
pr_warn("NMI backtrace for cpu %d skipped: idling at %pS\n",
99100
cpu, (void *)instruction_pointer(regs));
100101
} else {
102+
/*
103+
* Allow nested NMI backtraces while serializing
104+
* against other CPUs.
105+
*/
106+
printk_cpu_lock_irqsave(flags);
101107
pr_warn("NMI backtrace for cpu %d\n", cpu);
102108
if (regs)
103109
show_regs(regs);
104110
else
105111
dump_stack();
112+
printk_cpu_unlock_irqrestore(flags);
106113
}
107114
cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask));
108115
return true;

0 commit comments

Comments
 (0)