This is a note to let you know that I've just added the patch titled printk: Add panic_in_progress helper to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: printk-add-panic_in_progress-helper.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 638bff97b02854768b03c7de106b677613c51560 Author: Stephen Brennan <stephen.s.brennan@xxxxxxxxxx> Date: Wed Feb 2 09:18:18 2022 -0800 printk: Add panic_in_progress helper [ Upstream commit 77498617857f68496b360081dde1a492d40c28b2 ] This will be used help avoid deadlocks during panics. Although it would be better to include this in linux/panic.h, it would require that header to include linux/atomic.h as well. On some architectures, this results in a circular dependency as well. So instead add the helper directly to printk.c. Suggested-by: Petr Mladek <pmladek@xxxxxxxx> Signed-off-by: Stephen Brennan <stephen.s.brennan@xxxxxxxxxx> Reviewed-by: Petr Mladek <pmladek@xxxxxxxx> Reviewed-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx> Signed-off-by: Petr Mladek <pmladek@xxxxxxxx> Link: https://lore.kernel.org/r/20220202171821.179394-2-stephen.s.brennan@xxxxxxxxxx Stable-dep-of: d04d5882cd67 ("printk: Disable passing console lock owner completely during panic()") Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 8b110b245d92c..de44ccf9743c1 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -258,6 +258,11 @@ static void __up_console_sem(unsigned long ip) } #define up_console_sem() __up_console_sem(_RET_IP_) +static bool panic_in_progress(void) +{ + return unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID); +} + /* * This is used for debugging the mess that is the VT code by * keeping track if we have the console semaphore held. It's