Skip to content

Commit 4c3ba0d

Browse files
committed
printk/nbcon/panic: Allow printk kthread to sleep when the system is in panic
The printk kthread might be running when there is a panic in progress. But it is not able to acquire the console ownership any longer. Prevent the desperate attempts to acquire the ownership and allow sleeping in panic. It would make it behave the same as when there is any CPU in an emergency context. Reviewed-by: Andrew Murray <amurray@thegoodpenguin.co.uk> Reviewed-by: John Ogness <john.ogness@linutronix.de> Link: https://patch.msgid.link/20250926124912.243464-3-pmladek@suse.com [pmladek@suse.com: Rebased on top of 6.18-rc1 (panic_in_progress() moved to panic.c)] Signed-off-by: Petr Mladek <pmladek@suse.com>
1 parent c41c0eb commit 4c3ba0d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

kernel/printk/nbcon.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,8 @@ static bool nbcon_kthread_should_wakeup(struct console *con, struct nbcon_contex
11731173
* where the context with a higher priority takes over the nbcon console
11741174
* ownership in the middle of a message.
11751175
*/
1176-
if (unlikely(atomic_read(&nbcon_cpu_emergency_cnt)))
1176+
if (unlikely(atomic_read(&nbcon_cpu_emergency_cnt)) ||
1177+
unlikely(panic_in_progress()))
11771178
return false;
11781179

11791180
cookie = console_srcu_read_lock();
@@ -1231,7 +1232,8 @@ static int nbcon_kthread_func(void *__console)
12311232
* Block the kthread when the system is in an emergency or panic
12321233
* mode. See nbcon_kthread_should_wakeup() for more details.
12331234
*/
1234-
if (unlikely(atomic_read(&nbcon_cpu_emergency_cnt)))
1235+
if (unlikely(atomic_read(&nbcon_cpu_emergency_cnt)) ||
1236+
unlikely(panic_in_progress()))
12351237
goto wait_for_event;
12361238

12371239
backlog = false;

0 commit comments

Comments
 (0)