From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751477AbdJCWSL (ORCPT ); Tue, 3 Oct 2017 18:18:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:46310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751090AbdJCWSJ (ORCPT ); Tue, 3 Oct 2017 18:18:09 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3AB3214E0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Tue, 3 Oct 2017 18:18:06 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: pmladek@suse.com, sergey.senozhatsky@gmail.com, linux-kernel@vger.kernel.org, mingo@kernel.org, tglx@linutronix.de Subject: Re: [PATCH 2/3] early_printk: Add force_early_printk kernel parameter Message-ID: <20171003181806.5e0c0870@gandalf.local.home> In-Reply-To: <20170928122513.376168124@infradead.org> References: <20170928121823.430053219@infradead.org> <20170928122513.376168124@infradead.org> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 28 Sep 2017 14:18:25 +0200 Peter Zijlstra wrote: > Add add the 'force_early_printk' kernel parameter to override printk() > and force it into early_printk(). This bypasses all the cruft and fail > from printk() and makes things work again. Probably break this up into two patches. One for creation of early_vprintk(), and the other to add the force_early_printk parameter. -- Steve > > Signed-off-by: Peter Zijlstra (Intel) > --- > kernel/printk/printk.c | 68 +++++++++++++++++++++++++++++++++---------------- > 1 file changed, 47 insertions(+), 21 deletions(-) > > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -365,6 +365,42 @@ __packed __aligned(4) > #endif > ; > > +#ifdef CONFIG_EARLY_PRINTK > +struct console *early_console; > + > +static bool __read_mostly force_early_printk; > + > +static int __init force_early_printk_setup(char *str) > +{ > + force_early_printk = true; > + return 0; > +} > +early_param("force_early_printk", force_early_printk_setup); > + > +static int early_vprintk(const char *fmt, va_list args) > +{ > + char buf[512]; > + int n; > + > + n = vscnprintf(buf, sizeof(buf), fmt, args); > + early_console->write(early_console, buf, n); > + > + return n; > +} > + > +asmlinkage __visible void early_printk(const char *fmt, ...) > +{ > + va_list ap; > + > + if (!early_console) > + return; > + > + va_start(ap, fmt); > + early_vprintk(fmt, ap); > + va_end(ap); > +} > +#endif > + > /* > * The logbuf_lock protects kmsg buffer, indices, counters. This can be taken > * within the scheduler's rq lock. It must be released before calling > @@ -1816,6 +1852,11 @@ asmlinkage int vprintk_emit(int facility > return vkdb_printf(KDB_MSGSRC_PRINTK, fmt, args); > #endif > > +#ifdef CONFIG_EARLY_PRINTK > + if (force_early_printk && early_console) > + return early_vprintk(fmt, args); > +#endif > + > if (level == LOGLEVEL_SCHED) { > level = LOGLEVEL_DEFAULT; > in_sched = true; > @@ -1939,7 +1980,12 @@ asmlinkage __visible int printk(const ch > int r; > > va_start(args, fmt); > - r = vprintk_func(fmt, args); > +#ifdef CONFIG_EARLY_PRINTK > + if (force_early_printk && early_console) > + r = vprintk_default(fmt, args); > + else > +#endif > + r = vprintk_func(fmt, args); > va_end(args); > > return r; > @@ -1975,26 +2021,6 @@ static size_t msg_print_text(const struc > static bool suppress_message_printing(int level) { return false; } > #endif /* CONFIG_PRINTK */ > > -#ifdef CONFIG_EARLY_PRINTK > -struct console *early_console; > - > -asmlinkage __visible void early_printk(const char *fmt, ...) > -{ > - va_list ap; > - char buf[512]; > - int n; > - > - if (!early_console) > - return; > - > - va_start(ap, fmt); > - n = vscnprintf(buf, sizeof(buf), fmt, ap); > - va_end(ap); > - > - early_console->write(early_console, buf, n); > -} > -#endif > - > static int __add_preferred_console(char *name, int idx, char *options, > char *brl_options) > { >