Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Benedikt Spranger <b.spranger@linutronix.de>
Cc: Andrew Murray <amurray@thegoodpenguin.co.uk>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Russell King <linux@armlinux.org.uk>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	John Ogness <john.ogness@linutronix.de>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rpi-kernel@lists.infradead.org,
	linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code
Date: Tue, 7 Jul 2026 17:04:34 +0200	[thread overview]
Message-ID: <ak0VguIf-PxmbUOS@pathway.suse.cz> (raw)
In-Reply-To: <20260707145411.53a10893@mitra>

On Tue 2026-07-07 14:54:11, Benedikt Spranger wrote:
> On Mon, 6 Jul 2026 18:05:06 +0100
> Andrew Murray <amurray@thegoodpenguin.co.uk> wrote:
> 
> Hi Andrew,
> 
> > On Fri, 3 Jul 2026 at 15:56, Benedikt Spranger
> > <b.spranger@linutronix.de> wrote:
> > > On Tue, 30 Jun 2026 17:35:59 +0100
> > > Andrew Murray <amurray@thegoodpenguin.co.uk> wrote:
> > > > The printk_delay and boot_delay features are helpful for debugging
> > > > as kernel output can be slowed down during boot allowing messages
> > > > to be seen before scrolling off the screen, or to correlate timing
> > > > between some physical event and console output.
> > > By now, it slows down the boot process, which is the handy part of
> > > that feature.
> > >
> > > > However, since the introduction of nbcon and the legacy printer
> > > > thread for PREEMPT_RT kernels, printk records are now emited to
> > > > the console asynchronously to the caller of printk. Thus, any
> > > > printk delay added by boot_delay/printk_delay continues to slow
> > > > down the calling process but may not have any impact to the rate
> > > > in which records are emited to the console.
> > > Using this feature to slow down the boot/suspend/resume process and
> > > implicit make printk() happen, is the usefull part of that feature.
> > > Imagine this sequence (which hit me on suspend/resume on i.MX after
> > > shutting down all secondary CPUs)
> > >
> > >   printk("A");
> > >   (do some stuff)
> > >   printk("B");
> > >   read from peripheral --> system got stuck here since peripheral
> > > was not clocked or powered or both any more.
> > >
> > > The delay (and later on a ugly patch to make printk() synchrounous)
> > > helped to locate where the failed access happend. JTAG did not help,
> > > since the CPU got stuck --> no JTAG communication to that CPU.

First, it is great to know that people are actually using the
boot_delay and printk_delay features.

> > I understand the use-case, you sprinkle printk's so you can find the
> > point where a read to a register causes the CPU to stop. This requires
> > that the printk happens before the read, and the output from the
> > printk is printed before the read.
> Enabling existing debug features in the kernel was a good start.
> 
> > > With your purposed change you *may* see "A", but never "B".
> > > Quite challenging... 
> > At present you may see 'A' and you may see 'B'.
> That's correct. 
> 
> > Prior to the changes in this patchset, and assuming an nbcon console
> iMX swtched over to nbcon, so your assumption is correct.
> 
> > (which may not be your usecase, but is perhaps representative of
> > future use-cases), then the printk delay will always happen within the
> > call to printk (and always before emitting).
> Which is quite good, but can be better. (See the missing sync feature
> mentioned in Johns reply)
> 
> > However, depending on the context, that printk call may return (and
> > proceed to your CPU halting register read), before the message is
> > actually emitted to the console. I.e. it's a race.
> I am aware of that.
> 
> > This series moves the delay to the emit side, as well as moving the
> > delay after the emit. Thus the calling code may make progress more
> > quickly, but depending on the context, it may also flush/emit before
> > returning from printk.
> Unfortunately it makes things worse.
> 
> > In my view, with or without this series, there are no guarantees that
> > you will see 'A' and 'B'. And in any case, achieving the functionality
> > for debugging required you to modify the printk anyway.
> The "sync" feature is on the TODO list as John mentioned. 
> 
> > > So please leave the delay on the calling side - it is helpfull
> > > there.
> > 
> > If you want to ensure printk is synchronous, perhaps you could call
> > nbcon_cpu_emergency_enter() prior to your printk, or perhaps there are
> > already printk wrappers that do somthing similar whilst debugging?
> As said I did an ugly hack and forced printk() to be synchronous.
> 
> > Would that provide a more reliable way to guarantee output?
> It does.

To summarize this discussion:

  + Benedikt would prefer to add the synchronous mode before
    moving the delay from the printk() caller to the console emit
    code path.

  + The delay in the printk() caller code path did not guarantee
    the output but it increased the chance to see it.

  + The synchronous mode will be even more reliable than the delay
    in printk() caller path.

Please, let me know if I did not get it right,

John, did you have any plan how to add the synchronous mode, please?
Does it look complicated?

I guess that we would somehow need to "mis-use" the emergency
priority and force it everywhere by some global system setting.

Best Regards,
Petr


  reply	other threads:[~2026-07-07 15:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 16:35 [PATCH v2 0/4] printk: nbcon: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-06-30 16:35 ` [PATCH v2 1/4] printk: remove BOOT_PRINTK_DELAY config option Andrew Murray
2026-06-30 16:35 ` [PATCH v2 2/4] printk: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-07-08 15:01   ` Petr Mladek
2026-07-09 12:32     ` Andrew Murray
2026-07-09 14:26       ` Petr Mladek
2026-07-09 14:48         ` Andrew Murray
2026-06-30 16:35 ` [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code Andrew Murray
2026-07-03 12:57   ` John Ogness
2026-07-07 15:31     ` Petr Mladek
2026-07-08 10:36       ` John Ogness
2026-07-08 14:00         ` Petr Mladek
2026-07-09 15:27           ` Andrew Murray
2026-07-09 15:01     ` Andrew Murray
2026-07-03 14:56   ` Benedikt Spranger
2026-07-06 17:05     ` Andrew Murray
2026-07-07  7:34       ` John Ogness
2026-07-07 12:54       ` Benedikt Spranger
2026-07-07 15:04         ` Petr Mladek [this message]
2026-07-08  8:19           ` John Ogness
2026-07-08 14:26             ` Petr Mladek
2026-07-08 14:53               ` John Ogness
2026-07-08 15:09                 ` Petr Mladek
2026-07-08 15:24                   ` John Ogness
2026-07-09 14:27             ` Andrew Murray
2026-07-09 15:21               ` John Ogness
2026-06-30 16:36 ` [PATCH v2 4/4] Documentation/kernel-parameters: add/update printk_delay/boot_delay Andrew Murray

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=ak0VguIf-PxmbUOS@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=amurray@thegoodpenguin.co.uk \
    --cc=b.spranger@linutronix.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=corbet@lwn.net \
    --cc=florian.fainelli@broadcom.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=linux@armlinux.org.uk \
    --cc=rdunlap@infradead.org \
    --cc=rjui@broadcom.com \
    --cc=rostedt@goodmis.org \
    --cc=sbranden@broadcom.com \
    --cc=senozhatsky@chromium.org \
    --cc=skhan@linuxfoundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox