Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

printk: do not wait for consoles when suspended

The console_stop() and console_start() functions call pr_flush().
When suspending, these functions are called by the serial subsystem
while the serial port is suspended. In this scenario, if there are
any pending messages, a call to pr_flush() will always result in a
timeout because the serial port cannot make forward progress. This
causes longer suspend and resume times.

Add a check in pr_flush() so that it will immediately timeout if
the consoles are suspended.

Fixes: 3b604ca81202 ("printk: add pr_flush()")
Reported-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Tested-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20220715061042.373640-2-john.ogness@linutronix.de

authored by

John Ogness and committed by
Petr Mladek
9023ca08 07a22b61

+11 -2
+11 -2
kernel/printk/printk.c
··· 3380 3380 diff = 0; 3381 3381 3382 3382 console_lock(); 3383 + 3383 3384 for_each_console(c) { 3384 3385 if (con && con != c) 3385 3386 continue; ··· 3390 3389 if (printk_seq < seq) 3391 3390 diff += seq - printk_seq; 3392 3391 } 3393 - console_unlock(); 3394 3392 3395 - if (diff != last_diff && reset_on_progress) 3393 + /* 3394 + * If consoles are suspended, it cannot be expected that they 3395 + * make forward progress, so timeout immediately. @diff is 3396 + * still used to return a valid flush status. 3397 + */ 3398 + if (console_suspended) 3399 + remaining = 0; 3400 + else if (diff != last_diff && reset_on_progress) 3396 3401 remaining = timeout_ms; 3402 + 3403 + console_unlock(); 3397 3404 3398 3405 if (diff == 0 || remaining == 0) 3399 3406 break;