Re: [RFC][PATCH] printk: Fixup the nmi printk mess

Peter Zijlstra
2015-06-10T15:33:09Z

You are aware that you can delete bits of the email that are not
relevant, right?

On Wed, Jun 10, 2015 at 04:57:37PM +0200, Petr Mladek wrote:

> Also note that show_regs() calls many separate printk()s, the irqwork
> is scheduled by the first one => it is quite likely that some
> backtrace will get messed.

The irq_work is only ever called when we're inside an NMI, the irq_work
will only ever execute once that NMI is done -- on that CPU.

How will that miss anything?

> Anothrer problem is that __printk_nmi_flush() is per-CPU => more
> instances might be running in parallel. I haven't tested this but
> I quess that it will mix backtraces from different CPUs in
> the main ring buffer.

Correct, such is the life of printk().

> Note that the backtraces used to be serialized via
> static arch_spinlock_t lock = __ARCH_SPIN_LOCK_UNLOCKED
> in the past. See the commit
> a9edc8809328 ("x86/nmi: Perform a safe NMI stack trace on all CPUs")

We could easily add a static raw_spinlock_t to __printk_nmi_flush() and
serialize its invocations if people think that is important.