[PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code

Petr Mladek pmladek at suse.com
Wed Jul 8 07:26:18 PDT 2026


On Wed 2026-07-08 10:25:17, John Ogness wrote:
> On 2026-07-07, Petr Mladek <pmladek at suse.com> wrote:
> > 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.
> 
> The synchronous mode would rely on the driver being nbcon. I envision
> something like this:

Thanks for sharing the code.

> ---- BEGIN SYNC IDEA ----
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
> @@ -1200,7 +1200,7 @@ static bool nbcon_kthread_should_wakeup(struct console *con, struct nbcon_contex
>  	cookie = console_srcu_read_lock();
>  
>  	flags = console_srcu_read_flags(con);
> -	if (console_is_usable(con, flags, false)) {
> +	if (!(flags & CON_SYNC) &&  console_is_usable(con, flags, false)) {

The dependency on con->flags means that the sync mode can be entered
only in task context where synchronize_srcu() can be called. It might
be good enough. But I am afraid that people are creative and would
like to have even atomic variant sooner or later.

Also it will do the flush in NORMAL_PRIO which is good. But it might
fail to get the context ownership when it is blocked, for example,
by uart_port_lock() which might be even sleepable context in
PREEMPT_RT kernel.

>  		/* Bring the sequence in @ctxt up to date */
>  		ctxt->seq = nbcon_seq_read(con);
>  
> ---- END SYNC IDEA ----
> 
> BTW: The sync mode is the final piece so that PeterZ can start using
> mainline code for debugging by serial instead of his own workaround [0].

> [0] https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=debug/experimental

I see.

Best Regards,
Petr



More information about the linux-arm-kernel mailing list