Re: [PATCH printk v1 01/13] printk: rename cpulock functions

From: John Ogness
Date: Thu Feb 17 2022 - 09:34:42 EST


On 2022-02-15, Petr Mladek <pmladek@xxxxxxxx> wrote:
> This patch is about how to make it more obvious that this
> API has to be used carefully. I see the following main risks when
> using this API:
>
> + it might cause deadlocks, especially in panic
>
> + it is supposed to be tail lock (no other locks allowed in this
> context)
>
> + it is re-entrant
>
> + it does not prevent parallel (nested) access on the same CPU

I can add more information about the risks to the function documentation
(include/linux/printk.h).

> "get/put" are more acceptable for me. They create at lest some feeling
> that it tries to get something and it might take some time. Even
> thought many "get/put" APIs are not blocking.

OK. So I will keep the naming for the series v2.

> BTW: The API disables IRQ. So the nested access is limited to two
> levels: normal/IRQ and nested NMI contexts.

And there are reentrant call chains. For example, we already have:

nmi_cpu_backtrace()
printk_cpu_sync_get_irqsave(flags);
dump_stack();
printk_cpu_sync_get_irqsave(flags);
__dump_stack(log_lvl);
printk_cpu_sync_put_irqrestore(flags);
printk_cpu_sync_put_irqrestore(flags);

John