Re: [PATCH] nbcon/reboot: Flush nbcon consoles synchronously on reboot

From: John Ogness

Date: Mon Oct 12 2026 - 10:22:39 EST


On 2026-10-12, John Ogness <john.ogness@xxxxxxxxxxxxx> wrote:
>> while this seems okay, didn't we have pr_flush() to flush the output on
>> shutdown/ reboot?
>
> We have the syscore.ops.shutdown registered notifier that gracefully
> shuts down the kthread printers and transitions to atomic printing.
>
> There is a pr_flush() in kernel_power_off(), but actually that is no
> longer needed and should be removed.

After reviewing [0] I am reminded why pr_flush() exists in
kernel_power_off(). It is purely for legacy consoles on PREEMPT_RT.

I am wondering if instead printk_kthreads_shutdown() should make an
effort in this case (legacy + PREEMPT_RT):

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 0bbf6409d467a..10b655f05fa56 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3776,6 +3776,15 @@ static void printk_kthreads_shutdown(void *data)
*/
nbcon_atomic_flush_pending();
}
+
+ /*
+ * If legacy kthread printing is in use, give it a chance to
+ * flush any backlog. The kthread is not stopped because when
+ * forced, it is the only way legacy consoles can print.
+ */
+ if (force_legacy_kthread() && printk_legacy_kthread)
+ pr_flush(1000, true);
+
console_list_unlock();
}

That would still not cover the final "Power down", so probably the
pr_flush() should also continue to exist in kernel_power_off(). But it
is PREEMPT_RT + legacy specific, so I am not too happy about it.

John

[0] https://lore.kernel.org/lkml/a68e2e94-b4c6-4791-b581-ecbf3fee28e9@paulmck-laptop