printk: Avoid livelock with heavy printk during panic
authorStephen Brennan <stephen.s.brennan@oracle.com>
Wed, 2 Feb 2022 17:18:20 +0000 (09:18 -0800)
committerPetr Mladek <pmladek@suse.com>
Mon, 14 Feb 2022 12:39:20 +0000 (13:39 +0100)
commit13fb0f74d7029df3b8137f11ef955e578a4a4a60
treefe50763780a9ceda800bf31c5adc1d25ccafeaca
parentd51507098ff91e863b6e0a8047507741d59b8175
printk: Avoid livelock with heavy printk during panic

During panic(), if another CPU is writing heavily the kernel log (e.g.
via /dev/kmsg), then the panic CPU may livelock writing out its messages
to the console. Note when too many messages are dropped during panic and
suppress further printk, except from the panic CPU. This could result in
some important messages being dropped. However, messages are already
being dropped, so this approach at least prevents a livelock.

Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20220202171821.179394-4-stephen.s.brennan@oracle.com
kernel/printk/printk.c