All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Marek Behún" <kabel@kernel.org>,
	"John Ogness" <john.ogness@linutronix.de>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Sergey Senozhatsky" <senozhatsky@chromium.org>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
	"Jan Kara" <jack@suse.cz>,
	"Peter Zijlstra" <peterz@infradead.org>
Subject: Re: [PATCH] printk/console: Enable console kthreads only when there is no boot console left
Date: Tue, 21 Jun 2022 00:25:01 +0200	[thread overview]
Message-ID: <YrDzvX1fXWn5hMWL@alley> (raw)
In-Reply-To: <CAHk-=whBSrixcBVoWGnU0eoaksp82gnQ9_1jMNZsCzhLXEgEpw@mail.gmail.com>

On Mon 2022-06-20 14:10:20, Linus Torvalds wrote:
> On Mon, Jun 20, 2022 at 10:14 AM Petr Mladek <pmladek@suse.com> wrote:
> >
> > The console kthreads uncovered several races in console drivers.
> 
> I really want to make it clear that this was NOT some kind of "races
> in drivers".
>
> Console drivers may very well  have intentionally avoided taking locks
> for console output, since the printk output was supposed to be
> serialized by printk.
> 
> Don't try to make this some kind of "buggy drivers" thing. This is on
> printk, not on anything else.

OK, I see that uart_console_write() is used by
early_serial8250_write() without port->lock. It means that it is
racy against serial8250_console_write(). It might
cause problems reported by this thread. And you are
right that it has never been used in parallel before the kthreads.

But I believe that it might cause real problems. serial8250_console_write()
takes port->lock to get serialized against other operations on the
port. And there might be some when the same port is added as
a proper serial console.

Today I found that probe_baud() is called from
serial8250_console_setup() without port->lock. It does reads and
writes. I believe that it might break with the earlycon.

Also the commit 589f892ac8ef244e47c5a ("serial: meson:
acquire port->lock in startup()") fixes a race between
meson_serial_port_write() and meson_uart_startup(), where
meson_serial_port_write() is used by both early and proper
console driver. The problem was there even without kthreads.
They just made it more visible.

My colleagues familiar with ARM told me that they heard about
boot freezes with early consoles before threads. The kthreads
allow to reproduce and fix them. In the end, they make the early
consoles more reliable.


> Assuming this solves all issues, I'm ok with this approach, but I
> really want this to be clearly about printk being buggy, no "blame the
> drivers" garbage.
>
> And if there are other issues coming up, we revert the whole thing entirely.
> 
> Because printk is too important to play games with, and too important
> to try to blame drivers.

I take printk() really seriously. And I definitely do not want
to wave out problems as others problem.

I do not want to release 5.19 with broken printk(). But the kthreads
solve real bugs where printk() put the system into knees. I want
to invest much more time on improving them and fixing related
problems. Unfortunately, linux-next was not able to catch
the recently reported problems and we were not able to fix them
in advance.

All the recent fixes were generic and should make printk() with
kthreads much more reliable. I can't be sure if it will be enough.
I could only say that I am going to fix any new ones.

Of course, if people continue reporting problems, we would need
to revert it for 5.19. But I would really like to give it another
chance later.

Best Regards,
Petr

  reply	other threads:[~2022-06-20 22:25 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-19 18:49 Boot stall regression from "printk for 5.19" merge Marek Behún
2022-06-19 22:23 ` John Ogness
2022-06-19 22:31   ` John Ogness
2022-06-20 10:02     ` Marek Behún
2022-06-20  9:29   ` Marek Behún
2022-06-20 11:44     ` Petr Mladek
2022-06-20 11:47       ` Petr Mladek
2022-06-20 12:04         ` Ilpo Järvinen
2022-06-20 13:48       ` Linus Torvalds
2022-06-20 14:24         ` Petr Mladek
2022-06-20 15:14           ` [PATCH] printk/console: Enable console kthreads only when there is no boot console left Petr Mladek
2022-06-20 15:16             ` Petr Mladek
2022-06-20 18:38             ` Marek Behún
2022-06-20 19:10             ` Linus Torvalds
2022-06-20 22:25               ` Petr Mladek [this message]
2022-06-20 22:51             ` John Ogness
2022-06-24 22:41               ` Steven Rostedt
2022-06-29  8:29                 ` Petr Mladek
2022-06-20  5:23 ` Boot stall regression from "printk for 5.19" merge Sergey Senozhatsky
2022-06-20 10:02   ` Marek Behún
2022-06-20 10:13     ` Sergey Senozhatsky
2022-06-20 10:29       ` Marek Behún
2022-06-20 11:01         ` Andy Shevchenko
2022-06-20 10:38 ` Daniel Palmer
2022-06-21  9:39 ` Thorsten Leemhuis
2022-07-04  9:32   ` Boot stall regression from "printk for 5.19" merge #forregzbot Thorsten Leemhuis
2023-02-21 12:38 printk: console output corrupted André Pribil
2023-02-21 16:12 ` John Ogness
2023-02-21 16:15   ` [PATCH] printk/console: Enable console kthreads only when there is no boot console left John Ogness
2023-02-22 10:53     ` André Pribil
2023-02-22 14:35       ` André Pribil

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=YrDzvX1fXWn5hMWL@alley \
    --to=pmladek@suse.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=jack@suse.cz \
    --cc=john.ogness@linutronix.de \
    --cc=kabel@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=torvalds@linux-foundation.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.