Skip to contentSkip to conversation

printk: fix suppressed message print when reboot/panic

PATCH In review Schspa Shi 4 participants 7 messages Mar 21, 2022 – Jul 11, 2022 Printk

lore
Share & tools
lore

Schspa Shi

author
#0 lore raw

PATCH 1/1 printk: fix suppressed message print when reboot/panic

Update printk_seq for suppressed message.

Affects 5.9-rt and 5.10-rt

When message is suppressed, printk_seq should be updated, otherwise this message will be printed when reboot. This problem was introduced in commit 3edc0c85d154 ("printk: Rebase on top of new ring buffer").

---
 kernel/printk/printk.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
kernel/printk/printk.c +10 -2
index 0c56873396a9..f68c4ba7eb4d 100644
@@ -2826,8 +2826,17 @@ static int printk_kthread_func(void *data)
 		if (!(con->flags & CON_ENABLED))
 			continue;
 
-		if (suppress_message_printing(r.info->level))
+		printk_seq = atomic64_read(&con->printk_seq);
+
+		if (suppress_message_printing(r.info->level)) {
+			/*
+			 * Skip record we have buffered and already printed
+			 * directly to the console when we received it, and
+			 * record that has level above the console loglevel.
+			 */
+			atomic64_cmpxchg_relaxed(&con->printk_seq, printk_seq, seq);
 			continue;
+		}
 
 		if (con->flags & CON_EXTENDED) {
 			len = info_print_ext_header(ext_text,
@@ -2843,7 +2852,6 @@ static int printk_kthread_func(void *data)
 				printk_time);
 		}
 
-		printk_seq = atomic64_read(&con->printk_seq);
 
 		console_lock();
 		console_may_schedule = 0;
Signature · 1 line
2.29.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Schspa Shi

Update printk_seq for suppressed message.

Affects 5.9-rt and 5.10-rt

When message is suppressed, printk_seq should be updated, otherwise this message will be printed when reboot. This problem was introduced in commit 3edc0c85d154 ("printk: Rebase on top of new ring buffer").

Nice catch. Thanks.

5.15-rt also has this issue, although the fix is slightly different. For 5.15-rt, writing to con->printk_seq (via latched_seq_write()) requires the console locked. Would you like to post a patch for 5.15-rt as well, or would you like me to do it?

5.16 and beyond does not have this issue.

John Ogness

#5 lore raw
In reply to Schspa Shi
Quoted 7 lines · Schspa Shi

Update printk_seq for suppressed message.

Affects 5.9-rt and 5.10-rt

When message is suppressed, printk_seq should be updated, otherwise this message will be printed when reboot. This problem was introduced in commit 3edc0c85d154 ("printk: Rebase on top of new ring buffer").

So it is only 5.10 given that 5.9 is not maintained. That commits points to the printk update in v5.9.1-rt18. John?

Quoted 39 lines
---
 kernel/printk/printk.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
kernel/printk/printk.c +10 -2
index 0c56873396a9..f68c4ba7eb4d 100644
@@ -2826,8 +2826,17 @@ static int printk_kthread_func(void *data)
 		if (!(con->flags & CON_ENABLED))
 			continue;
 
-		if (suppress_message_printing(r.info->level))
+		printk_seq = atomic64_read(&con->printk_seq);
+
+		if (suppress_message_printing(r.info->level)) {
+			/*
+			 * Skip record we have buffered and already printed
+			 * directly to the console when we received it, and
+			 * record that has level above the console loglevel.
+			 */
+			atomic64_cmpxchg_relaxed(&con->printk_seq, printk_seq, seq);
 			continue;
+		}
 
 		if (con->flags & CON_EXTENDED) {
 			len = info_print_ext_header(ext_text,
@@ -2843,7 +2852,6 @@ static int printk_kthread_func(void *data)
 				printk_time);
 		}
 
-		printk_seq = atomic64_read(&con->printk_seq);
 
 		console_lock();
 		console_may_schedule = 0;
Signature · 1 line
2.29.0
author
#2 lore raw
In reply to John Ogness
Quoted 11 lines · John Ogness
Quoted 9 lines · Schspa Shi

Update printk_seq for suppressed message.

Affects 5.9-rt and 5.10-rt

When message is suppressed, printk_seq should be updated, otherwise this message will be printed when reboot. This problem was introduced in commit 3edc0c85d154 ("printk: Rebase on top of new ring buffer").

Quoted 9 lines

Nice catch. Thanks.

5.15-rt also has this issue, although the fix is slightly different. For 5.15-rt, writing to con->printk_seq (via latched_seq_write()) requires the console locked. Would you like to post a patch for 5.15-rt as well, or would you like me to do it?

I have upload a new patch for 5.15-rt, please review it too.
Message-Id: <[email protected]>

Quoted 3 lines

5.16 and beyond does not have this issue.

John Ogness

BRs

Schspa Shi

#3 lore raw
In reply to John Ogness

Luis,

Care to add this patch into the 5.10-rt stable?

Thanks,

-- Steve

Quoted 23 lines · On Mon, 21 Mar 2022 10:36:55 +0106 John Ogness <[email protected]>…
Quoted 9 lines · Schspa Shi

Update printk_seq for suppressed message.

Affects 5.9-rt and 5.10-rt

When message is suppressed, printk_seq should be updated, otherwise this message will be printed when reboot. This problem was introduced in commit 3edc0c85d154 ("printk: Rebase on top of new ring buffer").

Nice catch. Thanks.

5.15-rt also has this issue, although the fix is slightly different. For 5.15-rt, writing to con->printk_seq (via latched_seq_write()) requires the console locked. Would you like to post a patch for 5.15-rt as well, or would you like me to do it?

5.16 and beyond does not have this issue.

John Ogness

#4 lore raw

I guess the [email protected] is no longer valid. I need to update my address book :-/

Quoted 35 lines · On Mon, 11 Jul 2022 12:31:28 -0400 Steven Rostedt <[email protected]> wrote:

Luis,

Care to add this patch into the 5.10-rt stable?

Thanks,

-- Steve

Quoted 23 lines · On Mon, 21 Mar 2022 10:36:55 +0106 John Ogness <[email protected]>…
Quoted 9 lines · Schspa Shi

Update printk_seq for suppressed message.

Affects 5.9-rt and 5.10-rt

When message is suppressed, printk_seq should be updated, otherwise this message will be printed when reboot. This problem was introduced in commit 3edc0c85d154 ("printk: Rebase on top of new ring buffer").

Nice catch. Thanks.

5.15-rt also has this issue, although the fix is slightly different. For 5.15-rt, writing to con->printk_seq (via latched_seq_write()) requires the console locked. Would you like to post a patch for 5.15-rt as well, or would you like me to do it?

5.16 and beyond does not have this issue.

John Ogness