Re: [PATCH next v1 2/2] nmi_backtrace: use the printk cpu lock for show_regs()

From: Petr Mladek
Date: Tue Jun 01 2021 - 10:26:03 EST


On Mon 2021-05-31 18:20:51, John Ogness wrote:
> dump_stack() uses the printk cpu lock to synchronize the stacktrace,
> but this can also be used for dumping the banner and regs.
>
> Since the cpu lock allows recursive locking, it is not an issue to
> call dump_stack() with the printk cpu lock held.

This does not explain why it is serialized only in nmi_cpu_backtrace().

It would be better to serialize all show_regs() calls. But it would
require updating all the arch-specific implementations.

I know that this patch is a pre-requisite for another patchset
removing printk_safe(). Where printk_safe() is serializing
the backtraces from all CPUs at the moment.

IMHO, it is perfectly fine synchronize only nmi_cpu_backtrace() for
now. It is the most important use-case where show_regs() calls could
get messed easily. But I suggest to do it in the patchset removing
printk_safe(). Also we need to explain in the commit message the relation
to printk_safe().

Best Regards,
Petr