From: John Ogness Subject: [RFC PATCH v1 16/25] printk: implement CON_PRINTBUFFER Date: Tue, 12 Feb 2019 15:29:54 +0100 Message-ID: <20190212143003.48446-17-john.ogness@linutronix.de> References: <20190212143003.48446-1-john.ogness@linutronix.de> Return-path: In-Reply-To: <20190212143003.48446-1-john.ogness@linutronix.de> Sender: linux-kernel-owner@vger.kernel.org To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky List-Id: linux-serial@vger.kernel.org If the CON_PRINTBUFFER flag is not set, do not replay the history for that console. Signed-off-by: John Ogness --- kernel/printk/printk.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 6c875abd7b17..b97d4195b09a 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -399,10 +399,6 @@ static u32 log_first_idx; static u64 log_next_seq; static u32 log_next_idx; -/* the next printk record to write to the console */ -static u64 console_seq; -static u32 console_idx; - /* the next printk record to read after the last 'clear' command */ static u64 clear_seq; static u32 clear_idx; @@ -1596,8 +1592,12 @@ static void call_console_drivers(u64 seq, const char *ext_text, size_t ext_len, if (!(con->flags & CON_ENABLED)) continue; if (!con->wrote_history) { - printk_write_history(con, seq); - continue; + if (con->flags & CON_PRINTBUFFER) { + printk_write_history(con, seq); + continue; + } + con->wrote_history = 1; + con->printk_seq = seq - 1; } if (!con->write) continue; @@ -1822,8 +1822,6 @@ EXPORT_SYMBOL(printk); static u64 syslog_seq; static u32 syslog_idx; -static u64 console_seq; -static u32 console_idx; static u64 log_first_seq; static u32 log_first_idx; static u64 log_next_seq; @@ -2224,7 +2222,6 @@ early_param("keep_bootcon", keep_bootcon_setup); void register_console(struct console *newcon) { int i; - unsigned long flags; struct console *bcon = NULL; struct console_cmdline *c; static bool has_preferred; @@ -2340,16 +2337,6 @@ void register_console(struct console *newcon) if (newcon->flags & CON_EXTENDED) nr_ext_console_drivers++; - if (newcon->flags & CON_PRINTBUFFER) { - /* - * console_unlock(); will print out the buffered messages - * for us. - */ - logbuf_lock_irqsave(flags); - console_seq = syslog_seq; - console_idx = syslog_idx; - logbuf_unlock_irqrestore(flags); - } console_unlock(); console_sysfs_notify(); -- 2.11.0