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

From: John Ogness

Date: Wed Jul 08 2026 - 11:03:16 EST


On 2026-07-08, Petr Mladek <pmladek@xxxxxxxx> wrote:
>> The synchronous mode would rely on the driver being nbcon. I envision
>> something like this:
>>
>> ---- 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.

You mean it can only be _modified_ in task context. Yes. I expect it is
either specified as a boot arg or modified via some sysfs interface.

> 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.

Indeed. This is the same limitation of the atomic printing in
general. But I do not think this can be worked around during normal
operation. Ignoring locks is not an option.

John