In order to support printing the printk log history when new
consoles are registered, a global exclusive_console variable is
temporarily set. This only works because printk runs with
preemption disabled.

When console printing is moved to a fully preemptible dedicated
kthread, this hack no longer works.

Remove exclusive_console usage.

Signed-off-by: John Ogness <john.ogn...@linutronix.de>
---
 kernel/printk/printk.c | 30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 08e079b95652..5a5a685bb128 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -251,11 +251,6 @@ static void __up_console_sem(unsigned long ip)
 static int console_locked, console_suspended;
 
 /*
- * If exclusive_console is non-NULL then only this console is to be printed to.
- */
-static struct console *exclusive_console;
-
-/*
  *     Array of consoles built from command line options (console=)
  */
 
@@ -423,7 +418,6 @@ static u32 log_next_idx;
 /* the next printk record to write to the console */
 static u64 console_seq;
 static u32 console_idx;
-static u64 exclusive_console_stop_seq;
 
 /* the next printk record to read after the last 'clear' command */
 static u64 clear_seq;
@@ -1761,8 +1755,6 @@ static void call_console_drivers(const char *ext_text, 
size_t ext_len,
                return;
 
        for_each_console(con) {
-               if (exclusive_console && con != exclusive_console)
-                       continue;
                if (!(con->flags & CON_ENABLED))
                        continue;
                if (!con->write)
@@ -2044,7 +2036,6 @@ static u64 syslog_seq;
 static u32 syslog_idx;
 static u64 console_seq;
 static u32 console_idx;
-static u64 exclusive_console_stop_seq;
 static u64 log_first_seq;
 static u32 log_first_idx;
 static u64 log_next_seq;
@@ -2413,12 +2404,6 @@ void console_unlock(void)
                        goto skip;
                }
 
-               /* Output to all consoles once old messages replayed. */
-               if (unlikely(exclusive_console &&
-                            console_seq >= exclusive_console_stop_seq)) {
-                       exclusive_console = NULL;
-               }
-
                len += msg_print_text(msg,
                                console_msg_format & MSG_FORMAT_SYSLOG,
                                printk_time, text + len, sizeof(text) - len);
@@ -2736,17 +2721,6 @@ void register_console(struct console *newcon)
                logbuf_lock_irqsave(flags);
                console_seq = syslog_seq;
                console_idx = syslog_idx;
-               /*
-                * We're about to replay the log buffer.  Only do this to the
-                * just-registered console to avoid excessive message spam to
-                * the already-registered consoles.
-                *
-                * Set exclusive_console with disabled interrupts to reduce
-                * race window with eventual console_flush_on_panic() that
-                * ignores console_lock.
-                */
-               exclusive_console = newcon;
-               exclusive_console_stop_seq = console_seq;
                logbuf_unlock_irqrestore(flags);
        }
        console_unlock();
@@ -2758,6 +2732,10 @@ void register_console(struct console *newcon)
         * boot consoles, real consoles, etc - this is to ensure that end
         * users know there might be something in the kernel's log buffer that
         * went to the bootconsole (that they do not see on the real console)
+        *
+        * This message is also important because it will trigger the
+        * printk kthread to begin dumping the log buffer to the newly
+        * registered console.
         */
        pr_info("%sconsole [%s%d] enabled\n",
                (newcon->flags & CON_BOOT) ? "boot" : "" ,
-- 
2.11.0

Reply via email to