From: Petr Mladek <pmladek@suse.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: sergey.senozhatsky@gmail.com, linux-kernel@vger.kernel.org,
rostedt@goodmis.org, mingo@kernel.org, tglx@linutronix.de
Subject: Re: [PATCH 2/3] early_printk: Add force_early_printk kernel parameter
Date: Fri, 13 Oct 2017 15:06:09 +0200 [thread overview]
Message-ID: <20171013130609.GC2795@pathway.suse.cz> (raw)
In-Reply-To: <20171012113949.kb7xhrk6u27fqdc7@hirez.programming.kicks-ass.net>
On Thu 2017-10-12 13:39:49, Peter Zijlstra wrote:
> On Thu, Oct 12, 2017 at 12:24:19PM +0200, Petr Mladek wrote:
> > On Thu 2017-09-28 14:18:25, Peter Zijlstra wrote:
>
> > > +#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);
> >
> > The parameter is currently used only when CONFIG_PRINTK is enabled.
> > But CONFIG_EARLY_PRINTK is independent. What would be your preferred
> > behavior when CONFIG_PRINTK is disabled, please?
>
> Can we even have !PRINTK && EARLY_PRINTK? If so it seems to me continued
> usage of early_printk() is what makes most sense.
Yes, !PRINTK && EARLY_PRINTK is possible at the moment. It makes some
sense because EARLY_PRINTK needs only consoles and they are needed
also for !PRINTK stuff.
We either should define force_early_printk only when
PRINTK is enabled.
Or we should call early_printk() from printk() also when
PRINTK is disabled. The current implemetation is in
include/linux/printk.h, see
static inline __printf(1, 2) __cold
int printk(const char *s, ...)
{
return 0;
}
> > > @@ -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);
> >
> > There is rather theoretical race. We skip vprintk_func() because
> > we believe that vprintk_default()/vprintk_emit() would choose
> > handle this by early_printk().
>
> Do you mean if someone were to toggle force_early_printk at runtime?
Or that someone unregisters the early console.
> The reason I did it like this and not use that function pointer thing is
> that I didn't want to risk anybody hijacking my output ever.
I understand. I think about refactoring the code so that all
*printk*() variants call printk_func(). This function
could then call the right printk implementation according
to the context or global setting.
This way we could have all the logic on a single place and
avoid the race.
Note that printk_func() is not longer a pointer. It is
a function since the commit 099f1c84c0052ec1b2
("printk: introduce per-cpu safe_print seq buffer").
Best Regards,
Petr
next prev parent reply other threads:[~2017-10-13 13:06 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-28 12:18 [PATCH 0/3] printk: Add force_early_printk boot param Peter Zijlstra
2017-09-28 12:18 ` [PATCH 1/3] printk: Fix kdb_trap_printk placement Peter Zijlstra
2017-10-03 22:10 ` Steven Rostedt
2017-10-05 13:38 ` Petr Mladek
2017-10-05 13:42 ` Peter Zijlstra
2017-10-09 15:05 ` Petr Mladek
2017-10-12 9:45 ` Petr Mladek
2017-10-12 10:03 ` Petr Mladek
2017-10-12 11:34 ` Peter Zijlstra
2017-10-12 11:52 ` Greg Kroah-Hartman
2017-10-12 12:08 ` Greg Kroah-Hartman
2017-10-12 18:11 ` Joe Perches
2017-10-13 14:23 ` Petr Mladek
2017-10-12 11:30 ` Peter Zijlstra
2017-09-28 12:18 ` [PATCH 2/3] early_printk: Add force_early_printk kernel parameter Peter Zijlstra
2017-09-28 15:41 ` Randy Dunlap
2017-09-28 16:07 ` Peter Zijlstra
2017-09-28 17:05 ` Randy Dunlap
2017-10-03 22:18 ` Steven Rostedt
2017-10-12 10:24 ` Petr Mladek
2017-10-12 11:39 ` Peter Zijlstra
2017-10-13 13:06 ` Petr Mladek [this message]
2017-10-13 13:20 ` Peter Zijlstra
2017-10-13 13:30 ` Steven Rostedt
2017-09-28 12:18 ` [PATCH 3/3] early_printk: Add simple serialization to early_vprintk() Peter Zijlstra
2017-10-03 22:24 ` Steven Rostedt
2017-10-04 9:08 ` Peter Zijlstra
2017-10-04 13:04 ` Steven Rostedt
2017-10-04 13:08 ` Peter Zijlstra
2017-10-04 14:17 ` Paul E. McKenney
2017-10-04 14:43 ` Steven Rostedt
2017-10-04 14:52 ` Peter Zijlstra
2017-10-04 15:02 ` Steven Rostedt
2017-10-04 15:14 ` Paul E. McKenney
2017-10-04 15:24 ` Peter Zijlstra
2017-10-04 15:38 ` Paul E. McKenney
2017-09-28 16:02 ` [PATCH 0/3] printk: Add force_early_printk boot param Sergey Senozhatsky
2017-09-28 16:17 ` Peter Zijlstra
-- strict thread matches above, loose matches on Subject: below --
2016-10-18 17:08 [PATCH 0/3] make printk work again Peter Zijlstra
2016-10-18 17:08 ` [PATCH 2/3] early_printk: Add force_early_printk kernel parameter Peter Zijlstra
2016-11-29 14:02 ` Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171013130609.GC2795@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®