Re: [PATCH next v1 1/2] dump_stack: move cpu lock to printk.c
From: Petr Mladek
Date: Thu Jun 03 2021 - 02:33:17 EST
On Tue 2021-06-01 16:21:52, John Ogness wrote:
> On 2021-06-01, Petr Mladek <pmladek@xxxxxxxx> wrote:
> >> +void printk_cpu_lock(unsigned int *cpu_store, unsigned long *flags)
> >
> > I think about calling this printk_cpu_lock_irqsave() to make it clear
> > that it disables interrupts.
>
> Agreed.
>
> > Strictly speaking, it should be enough to disable preemption. If it is
> > safe when interrupted by NMI, it must be safe also when interrupted
> > by a normal interrupt.
> >
> > I guess that the interrupts are disabled because it reduces the risk
> > of nested (messed) backtraces.
>
> If it was just about synchronizing output triggered by sysreq, then it
> probably would be acceptable to leave interrupts active. But when atomic
> consoles are involved, we are talking about a crashing machine that is
> trying to get log messages out. Any interrupt is a risk that the machine
> may not survive long enough to return from that interruption.
Fair enough. It might be good to mention this motivation in the commit
message or in a code commentary. IMHO, it is always good to know
whether these things a must to have or if there is another reason.
Anyway, it was not obvious to me ;-)
Best Regards,
Petr