[PATCH v7 01/13] printk: Avoid delaying messages that aren't solicited by any console

Chris Down posted 13 patches 1 week, 6 days ago
There is a newer version of this series
[PATCH v7 01/13] printk: Avoid delaying messages that aren't solicited by any console
Posted by Chris Down 1 week, 6 days ago
printk_delay() may introduce delays even when no console wants to emit
the message, which is unnecessary and may hold back messages we actually
care about. Add a check in printk_delay() to determine if any console
will print the message to avoid introducing unnecessary delays. This
change aligns with the existing behaviour of boot-delayed printk
messages, which already have a similar check.

Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Chris Down <chris@chrisdown.name>
---
 kernel/printk/printk.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 5aee9ffb16b9..ff8b6dbb29a7 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1307,14 +1307,12 @@ static int __init boot_delay_setup(char *str)
 }
 early_param("boot_delay", boot_delay_setup);
 
-static void boot_delay_msec(int level)
+static void boot_delay_msec(void)
 {
 	unsigned long long k;
 	unsigned long timeout;
-	bool suppress = !is_printk_force_console() &&
-			suppress_message_printing(level);
 
-	if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING) || suppress)
+	if (boot_delay == 0 || system_state >= SYSTEM_RUNNING)
 		return;
 
 	k = (unsigned long long)loops_per_msec * boot_delay;
@@ -1334,7 +1332,7 @@ static void boot_delay_msec(int level)
 	}
 }
 #else
-static inline void boot_delay_msec(int level)
+static inline void boot_delay_msec(void)
 {
 }
 #endif
@@ -2116,7 +2114,11 @@ int printk_delay_msec __read_mostly;
 
 static inline void printk_delay(int level)
 {
-	boot_delay_msec(level);
+	/* If the message is forced (e.g. panic), we must delay */
+	if (!is_printk_force_console() && suppress_message_printing(level))
+		return;
+
+	boot_delay_msec();
 
 	if (unlikely(printk_delay_msec)) {
 		int m = printk_delay_msec;
-- 
2.51.2
Re: [PATCH v7 01/13] printk: Avoid delaying messages that aren't solicited by any console
Posted by Chris Down 1 week, 6 days ago
Of course, one reviews the whole patch set and then misses...

Chris Down writes:
>-	boot_delay_msec(level);
>+	/* If the message is forced (e.g. panic), we must delay */

That should obviously say "_not_ delay". I'll fix it on next resend.

>+	if (!is_printk_force_console() && suppress_message_printing(level))
>+		return;
>+
>+	boot_delay_msec();
Re: [PATCH v7 01/13] printk: Avoid delaying messages that aren't solicited by any console
Posted by Petr Mladek 1 week, 5 days ago
On Wed 2025-11-19 03:33:20, Chris Down wrote:
> Of course, one reviews the whole patch set and then misses...

I think that this is a classic post-sent panic ;-)

> Chris Down writes:
> > -	boot_delay_msec(level);
> > +	/* If the message is forced (e.g. panic), we must delay */
> 
> That should obviously say "_not_ delay". I'll fix it on next resend.

IMHO, the original message is correct. The message is forced => shown
 => the delay allows to read the message on a screen.

> > +	if (!is_printk_force_console() && suppress_message_printing(level))
> > +		return;
> > +
> > +	boot_delay_msec();

Best Regards,
Petr