The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Rik van Riel <riel@surriel.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
	mingo@redhat.com, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	vschneid@redhat.com
Subject: Re: [PATCH 0/9] sched: make WARN_ON under rq->lock deadlock-safe (SCHED_WARN_ON)
Date: Thu, 11 Jun 2026 21:19:22 +0200	[thread overview]
Message-ID: <20260611191922.GK187714@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <bc61cec71c284361882b5cc19f8520e2e85ec133.camel@surriel.com>

On Thu, Jun 11, 2026 at 12:20:27PM -0400, Rik van Riel wrote:
> On Thu, 2026-06-11 at 09:43 +0200, Peter Zijlstra wrote:
> > 
> > Sorry, no. I've said it before and I'll stick with it. Just no.
> > 
> > printk_deferred() is an abomination, it means that if you mess up the
> > machine properly you'll *NEVER* see the output.
> > 
> > As per always, printk() is the one that needs fixing, and IIRC they
> > were
> > very close to getting there.
> 
> Printk to certain console types is always deferred,
> by default, because trying to synchronously print
> everything to a slow serial console can lead to a
> system softlockup panic.
> 
> In fact, this particular lockup is due to the
> printk being passed off to a worker thread, and
> the kernel deadlocking when the wakeup code
> tries to grab the runqueue lock its CPU already
> holds.
> 
> You are right that this could be fixed in the
> printk code, but the solution there will by
> necessity continue to contain some deferring.
> 
> 
> I suppose the printk code could use something
> like an irq work to wake up the printk worker,
> and avoid the scheduler deadlock that way?
> 
> I'm not sure that would make things more
> reliable, though...

The non-atomic consoles will always need a buffer, but atomic consoles
can (and should IMO) push out the messages immediately.

Anyway, the thing that keeps tripping is that console_sem thing, that
should just entirely go away. That thing ends up doing a wakeup from
printk() call context, which obviously doesn't work when inside the
scheduler locks.

So printk should:

 - stick msg in buffer (lockless)
 - print to atomic consoles (lockless)
 - use irq_work to wake console kthreads (lockless)
 - each kthread then tries to flush buffer to its own non-atomic console
   in non-atomic context.

From what I understand, we're very close to having this work. The only
disagreement between printk people an me is about defaults IIRC. I want
to have the serial console default to atomic, they want it to be an
option. But whatever, as long as I can specify on the kernel cmdline
that my serial should be atomic I'm good.

Myself, I almost exclusively run with earlycon serial and force printk
to be early_printk() (effectively not using printk at all). This works
perfectly fine and is the most reliable thing ever. I can push out
characters to the UART from any context.

And sure, sometimes its gets a little scrambled, but meh.

I have this working with real actual serial, IPMI/serial-over-lan and
AMT/serial-over-lan.

And if a machine doesn't have serial, its a paperweight ;-)

Now, of course I also use trace_printk() a lot, but for those moments
when the machine goes down hard, nothing beats serial.

  reply	other threads:[~2026-06-11 19:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  2:14 [PATCH 0/9] sched: make WARN_ON under rq->lock deadlock-safe (SCHED_WARN_ON) Rik van Riel
2026-06-11  2:14 ` [PATCH 1/9] sched: add SCHED_WARN_ON()/SCHED_WARN_ON_ONCE()/SCHED_WARN()/SCHED_WARN_ONCE() Rik van Riel
2026-06-11  2:14 ` [PATCH 2/9] sched/core: defer WARN console output under rq->lock Rik van Riel
2026-06-11  2:14 ` [PATCH 3/9] sched/fair: " Rik van Riel
2026-06-11  2:14 ` [PATCH 4/9] sched/deadline: " Rik van Riel
2026-06-11  2:14 ` [PATCH 5/9] sched/rt: " Rik van Riel
2026-06-11  2:14 ` [PATCH 6/9] sched_ext: " Rik van Riel
2026-06-11  2:14 ` [PATCH 7/9] sched/core_sched: " Rik van Riel
2026-06-11  2:14 ` [PATCH 8/9] sched/deadline: " Rik van Riel
2026-06-11  2:14 ` [PATCH 9/9] sched/rt: " Rik van Riel
2026-06-11  7:43 ` [PATCH 0/9] sched: make WARN_ON under rq->lock deadlock-safe (SCHED_WARN_ON) Peter Zijlstra
2026-06-11 16:20   ` Rik van Riel
2026-06-11 19:19     ` Peter Zijlstra [this message]
2026-06-12  1:53       ` Rik van Riel
2026-06-12  6:52         ` Peter Zijlstra

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=20260611191922.GK187714@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=riel@surriel.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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