From: John Ogness <john.ogness@linutronix.de>
To: Xiaochun Li <lixiaochun@open-hieco.net>, pmladek@suse.com
Cc: rostedt@goodmis.org, senozhatsky@chromium.org,
linux-kernel@vger.kernel.org,
Xiaochun Li <lixiaochun@open-hieco.net>
Subject: Re: [PATCH v1] printk: Unconditionally unregister boot consoles when any real console appears
Date: Mon, 18 May 2026 12:22:56 +0206 [thread overview]
Message-ID: <87mrxxuinb.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <20260518084251.3887779-1-lixiaochun@open-hieco.net>
Hi Xiaochun,
On 2026-05-18, Xiaochun Li <lixiaochun@open-hieco.net> wrote:
> The design of kernel message printing ensures that boot consoles are
> temporary and should be unregistered once a real console appears,
> preventing duplicate output without any loss of kernel messages.
>
> But currently, when multiple "console=" parameters are specified
> (e.g., console=ttyS0 console=ttyS1) together with a boot console
> (earlyprintk=ttyS0 and/or earlycon=uart,io,0x3f8), the boot console
> remains active indefinitely. As a result, after the real console
> active, each kernel message line is printed twice consecutively that
> is not as expected.
Although specifying multiple consoles using the same driver is improper
usage, I would still consider this a bug. Thanks for pointing this out.
(The fact that you cannot specify multiple consoles with the same driver
is a ridiculous historical artifact... but that is another topic.)
> Currently, register_console() unregisters boot consoles only when the
> newly registered console has CON_CONSDEV (i.e., it is the preferred
> console). However, when multiple "console=" arguments are given for
> the same driver (e.g., 8250), the try_enable_preferred_console()
> matches only the first console_cmdline entry and returns immediately.
> The enabled real console (ttyS0) is therefore not the preferred one
> and does not set CON_CONSDEV, because preferred_console points to the
> last entry (ttyS1). Consequently, the boot console is never unregistered.
>
> Fix this issue by removing the CON_CONSDEV requirement and
> unregistering all boot consoles whenever any real console
> (i.e., any console without CON_BOOT flag) is registered
I do not think this is the correct fix. It relies on the buggy
unregister_console_locked() code that even warns:
* <HISTORICAL>
* If this isn't the last console and it has CON_CONSDEV set, we
* need to set it on the next preferred console.
* </HISTORICAL>
*
* The above makes no sense as there is no guarantee that the next
* console has any device attached. Oh well....
I expect that the correct fix would be to make sure the registered
regular console gets CON_CONSDEV if the preferred console could not be
registered.
Or maybe the unregister_console_locked() should be fixed so that there
is a proper fallback when a CON_CONSDEV console unregisters.
The preferred console code is quite tricky and is even in the process of
being cleaned up. (Although the bug is present after applying the
cleanup series as well.)
John
[0] https://lore.kernel.org/lkml/20260423130015.85175-1-pmladek@suse.com
next prev parent reply other threads:[~2026-05-18 10:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 8:42 [PATCH v1] printk: Unconditionally unregister boot consoles when any real console appears Xiaochun Li
2026-05-18 10:16 ` John Ogness [this message]
2026-05-20 2:14 ` Xiaochun Li
2026-05-22 14:46 ` Petr Mladek
2026-05-25 1:38 ` Xiaochun Li
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=87mrxxuinb.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=lixiaochun@open-hieco.net \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.