Re: [PATCH 4.19 regression fix] printk: For early boot messages check loglevel when flushing the buffer

From: Sergey Senozhatsky
Date: Thu Sep 06 2018 - 03:29:49 EST


On (09/05/18 13:02), Petr Mladek wrote:
> Note that the first registered console prints all messages
> even without this flag.

Hmm, OK, interesting point.

I assumed that the first console usually has CON_PRINTBUFFER bit set.
Or even a CON_PRINTBUFFER | CON_ANYTIME combo. E.g. 8250. It sort of
makes sense to have CON_PRINTBUFFER for the first console. Any later
consoles [e.g. fbcon, netcon] don't necessarily have CON_PRINTBUFFER.

So by the time we have callable console "quite" param should be already
parsed [except the earlycon case perhaps]:

kernel_init_freeable
do_one_initcall
register_console
happens after
setup_arch
parse_early_param
quiet_kernel/debug_kernel.

And
setup_arch
parse_early_param
quiet_kernel/debug_kernel
happens before
console_init
con_init
register_console.

And the first console has CON_PRINTBUFFER bit set. Well, just because
it sounds reasonable. Those were the main assumptions behind my code
snippet. Was any of those assumptions wrong?

> I played with another solution, see the patch below. It defines
> which messages have a valid NOCONS flag according to the msg_seq
> number. IMHO, it is a bit more straightforward but it is still
> a hack. I am not super happy about it.

I just skimmed through it, and probably missed some parts. But I sort
of expected to see some console_valid_nocons_seq manipulations in
register_console(), when we register a new CON_PRINTBUFFER console
on already running system.

> Hmm, I seriously think about reverting the commit 375899cddcbb
> ("printk: make sure to print log on console.") and solving it
> another way.

I can agree, definitely. That's one of the options.

-ss