From: Derek Barbosa <debarbos@redhat.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
printk@lists.linux.dev, linux-kernel@vger.kernel.org,
Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH printk] printk: Avoid multiple unregistration in unregister_console_locked()
Date: Thu, 29 Oct 2026 17:31:28 -0400 [thread overview]
Message-ID: <auOyyCup1fTYvM_z@debarbos-thinkpadt14gen5.rmtusma.csb> (raw)
In-Reply-To: <87y0bgwm0y.fsf@jogness.linutronix.de>
On Thu, Oct 29, 2026 at 04:48:53PM +0106, John Ogness wrote:
> On 2026-10-29, Sashiko wrote:
> >> @@ -4471,6 +4493,9 @@ static int __init printk_late_init(void)
> >> }
> >>
> >> unregister_console_locked(con);
> >> +
> >> + /* Changed console list, may require printer threads to start/stop. */
> >> + printk_kthreads_check_locked();
> >> }
> >
> > Should printk_kthreads_check_locked() be called after the
> > hlist_for_each_entry_safe(con, tmp, &console_list, node) loop in
> > printk_late_init() rather than inside the loop body?
> >
> > In kernel/printk/printk.c:printk_late_init():
> >
> > hlist_for_each_entry_safe(con, tmp, &console_list, node) {
> > if (!(con->flags & CON_BOOT))
> > continue;
> > ...
> > unregister_console_locked(con);
> >
> > /* Changed console list, may require printer threads to start/stop. */
> > printk_kthreads_check_locked();
> > }
> > console_list_unlock();
> >
> > Because printk_kthreads_check_locked() is placed inside the loop,
> > unregistering the last boot console sets have_boot_console to false and
> > immediately attempts to start printer kthreads while the loop is still
> > iterating over console_list.
> >
> > If kthread creation in legacy_kthread_create() or nbcon_kthread_create()
> > fails for the console stored in tmp, printk_kthreads_check_locked() calls
> > unregister_console_locked() on that console, removing it with
> > hlist_del_init_rcu(), freeing nbcon resources, and invoking console->exit().
> > On the next iteration of printk_late_init(), con is set to tmp, accessing the
> > already-unregistered console and terminating the walk early because
> > hlist_del_init_rcu() cleared tmp->next.
>
> Geez, sorry. Obviously printk_kthreads_check_locked() needs to be
> outside of the hlist_for_each_entry_safe(console_list) loop. That was
> the whole point of the series!
>
> I will wait a day for v2 in case there is any feedback regarding my
> comments (or lack thereof).
Thank you for adding in the comments above check_locked and
unregister_console_lock :)
In fact, It looks like it even helped Sashiko catch this.
Once v2 is live I will pull it down and spin some tests.
>
> John
>
--
Derek <debarbos@redhat.com>
next prev parent reply other threads:[~2026-10-29 21:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 15:24 John Ogness
2026-10-29 15:42 ` John Ogness
2026-10-29 21:31 ` Derek Barbosa [this message]
[not found] <87y0bgwm0y.fsf@jogness.linutronix.deq>
2026-10-30 13:52 ` 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=auOyyCup1fTYvM_z@debarbos-thinkpadt14gen5.rmtusma.csb \
--to=debarbos@redhat.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=printk@lists.linux.dev \
--cc=rostedt@goodmis.org \
--cc=sashiko-bot@kernel.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 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®