diff options
author | John Ogness <john.ogness@linutronix.de> | 2021-07-15 21:33:54 +0200 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2021-07-26 15:07:15 +0200 |
commit | 55d6af1d66885059ffc2ac23083de52d12be63bb (patch) | |
tree | 8d579c4744333fb96485a6e82b5b0945096952f8 /lib/nmi_backtrace.c | |
parent | Merge branch 'akpm' (patches from Andrew) (diff) | |
download | linux-55d6af1d66885059ffc2ac23083de52d12be63bb.tar.xz linux-55d6af1d66885059ffc2ac23083de52d12be63bb.zip |
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 <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20210715193359.25946-2-john.ogness@linutronix.de
Diffstat (limited to 'lib/nmi_backtrace.c')
-rw-r--r-- | lib/nmi_backtrace.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c index 8abe1870dba4..dae233c5f597 100644 --- a/lib/nmi_backtrace.c +++ b/lib/nmi_backtrace.c @@ -92,17 +92,24 @@ module_param(backtrace_idle, bool, 0644); bool nmi_cpu_backtrace(struct pt_regs *regs) { int cpu = smp_processor_id(); + unsigned long flags; if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) { if (!READ_ONCE(backtrace_idle) && regs && cpu_in_idle(instruction_pointer(regs))) { pr_warn("NMI backtrace for cpu %d skipped: idling at %pS\n", cpu, (void *)instruction_pointer(regs)); } else { + /* + * Allow nested NMI backtraces while serializing + * against other CPUs. + */ + printk_cpu_lock_irqsave(flags); pr_warn("NMI backtrace for cpu %d\n", cpu); if (regs) show_regs(regs); else dump_stack(); + printk_cpu_unlock_irqrestore(flags); } cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask)); return true; |