Skip to contentSkip to conversation

printk: report boot console names during cut-over

PATCH RESEND Superseded Kees Cook 2 participants 3 messages Sep 20, 2013 – Sep 23, 2013 Printk

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH RESEND 1/1 printk: report boot console names during cut-over

This reports the names of boot consoles as they're being disabled to help identify which is which during cut-over. Helps answer the question "which boot console actually got activated?" once the regular console is running, mostly when debugging boot console failures.

---
 kernel/printk/printk.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
kernel/printk/printk.c +10 -6
index b4e8500..0dc54c9 100644
@@ -2361,14 +2361,18 @@ void register_console(struct console *newcon)
 	if (bcon &&
 	    ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV) &&
 	    !keep_bootcon) {
-		/* we need to iterate through twice, to make sure we print
-		 * everything out, before we unregister the console(s)
+		/* We need to iterate through all boot consoles, to make
+		 * sure we print everything out, before we unregister them.
 		 */
-		printk(KERN_INFO "console [%s%d] enabled, bootconsole disabled\n",
-			newcon->name, newcon->index);
-		for_each_console(bcon)
-			if (bcon->flags & CON_BOOT)
+		for_each_console(bcon) {
+			if (bcon->flags & CON_BOOT) {
+				printk(KERN_INFO "console [%s%d] enabled, "
+					"bootconsole [%s%d] disabled\n",
+					newcon->name, newcon->index,
+					bcon->name, bcon->index);
 				unregister_console(bcon);
+			}
+		}
 	} else {
 		printk(KERN_INFO "%sconsole [%s%d] enabled\n",
 			(newcon->flags & CON_BOOT) ? "boot" : "" ,
Signature · 6 lines
1.7.9.5


-- 
Kees Cook
Chrome OS Security
#1 lore raw
Quoted 24 lines · Kees Cook

This reports the names of boot consoles as they're being disabled to help identify which is which during cut-over. Helps answer the question "which boot console actually got activated?" once the regular console is running, mostly when debugging boot console failures.

---
 kernel/printk/printk.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
kernel/printk/printk.c +2 -3
index b4e8500..0dc54c9 100644
@@ -2361,14 +2361,18 @@ void register_console(struct console *newcon)
 	if (bcon &&
 	    ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV) &&
 	    !keep_bootcon) {
-		/* we need to iterate through twice, to make sure we print
-		 * everything out, before we unregister the console(s)
+		/* We need to iterate through all boot consoles, to make
+		 * sure we print everything out, before we unregister them.
 		 */
-		printk(KERN_INFO "console [%s%d] enabled, bootconsole disabled\n",

kernel/printk/printk.c void register_console(struct console *newcon) · line 2373

Quoted 10 lines
kernel/printk/printk.c +6 -3
-			newcon->name, newcon->index);
-		for_each_console(bcon)
-			if (bcon->flags & CON_BOOT)
+		for_each_console(bcon) {
+			if (bcon->flags & CON_BOOT) {
+				printk(KERN_INFO "console [%s%d] enabled, "
+					"bootconsole [%s%d] disabled\n",
+					newcon->name, newcon->index,
+					bcon->name, bcon->index);
 				unregister_console(bcon);

Looks useful! But I think the "console %foo disabled" message should move to unregister_console() instead. That way it also handles printk_late_init() and all other console unregisters.

Thanks.

author
#2 lore raw
Quoted 30 lines · Frederic Weisbecker
Quoted 29 lines · Kees Cook

This reports the names of boot consoles as they're being disabled to help identify which is which during cut-over. Helps answer the question "which boot console actually got activated?" once the regular console is running, mostly when debugging boot console failures.

---
 kernel/printk/printk.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
kernel/printk/printk.c +4 -6
index b4e8500..0dc54c9 100644
@@ -2361,14 +2361,18 @@ void register_console(struct console *newcon)
      if (bcon &&
          ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV) &&
          !keep_bootcon) {
-             /* we need to iterate through twice, to make sure we print
-              * everything out, before we unregister the console(s)
+             /* We need to iterate through all boot consoles, to make
+              * sure we print everything out, before we unregister them.
               */
-             printk(KERN_INFO "console [%s%d] enabled, bootconsole disabled\n",
-                     newcon->name, newcon->index);
-             for_each_console(bcon)
-                     if (bcon->flags & CON_BOOT)
+             for_each_console(bcon) {
+                     if (bcon->flags & CON_BOOT) {
Quoted 8 lines

kernel/printk/printk.c void register_console(struct console *newcon) · line 2373

Quoted 5 lines
kernel/printk/printk.c +4 -0
+                             printk(KERN_INFO "console [%s%d] enabled, "
+                                     "bootconsole [%s%d] disabled\n",
+                                     newcon->name, newcon->index,
+                                     bcon->name, bcon->index);
                              unregister_console(bcon);

Looks useful! But I think the "console %foo disabled" message should move to unregister_console() instead. That way it also handles printk_late_init() and all other console unregisters.

Yeah, that's a much cleaner way to do this. I'll send a new patch. Thanks!

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security