Re: [PATCH v2 4/4] printk: Drop console_sem during panic

From: John Ogness
Date: Thu Jan 27 2022 - 04:23:01 EST


On 2022-01-26, Stephen Brennan <stephen.s.brennan@xxxxxxxxxx> wrote:
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2759,7 +2782,7 @@ void console_unlock(void)
> * flush, no worries.
> */
> retry = prb_read_valid(prb, next_seq, NULL);
> - if (retry && console_trylock())
> + if (retry && !abandon_console_lock_in_panic() && console_trylock())

As Sergey suggested [0], I would like to see the call to
abandon_console_lock_in_panic() move inside console_trylock(). This will
help to avoid the race between NMI CPU halt and the internal sema.lock
spinlock.

John Ogness

[0] https://lore.kernel.org/all/YfJFjHdg%2FkhNXiRd@xxxxxxxxxx