diff options
| author | John Ogness <john.ogness@linutronix.de> | 2025-11-13 17:09:47 +0106 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-01-02 12:57:09 +0100 |
| commit | be8ba672cc5ae52e8a10ac8eddb89d88f66b3cab (patch) | |
| tree | 3a810b4370b9a313e78fa02653bf59135db1006f /kernel | |
| parent | b107196729ff6b9d6cde0a71f49c1243def43328 (diff) | |
| download | linux-be8ba672cc5ae52e8a10ac8eddb89d88f66b3cab.tar.gz linux-be8ba672cc5ae52e8a10ac8eddb89d88f66b3cab.tar.bz2 linux-be8ba672cc5ae52e8a10ac8eddb89d88f66b3cab.zip | |
printk: Allow printk_trigger_flush() to flush all types
commit d01ff281bd9b1bfeac9ab98ec8a9ee41da900d5e upstream.
Currently printk_trigger_flush() only triggers legacy offloaded
flushing, even if that may not be the appropriate method to flush
for currently registered consoles. (The function predates the
NBCON consoles.)
Since commit 6690d6b52726 ("printk: Add helper for flush type
logic") there is printk_get_console_flush_type(), which also
considers NBCON consoles and reports all the methods of flushing
appropriate based on the system state and consoles available.
Update printk_trigger_flush() to use
printk_get_console_flush_type() to appropriately flush registered
consoles.
Suggested-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/stable/20251113160351.113031-2-john.ogness%40linutronix.de
Tested-by: Sherry Sun <sherry.sun@nxp.com>
Link: https://patch.msgid.link/20251113160351.113031-2-john.ogness@linutronix.de
Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/printk/nbcon.c | 2 | ||||
| -rw-r--r-- | kernel/printk/printk.c | 23 |
2 files changed, 23 insertions, 2 deletions
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c index da07c59f7aa2..730d14f6cbc5 100644 --- a/kernel/printk/nbcon.c +++ b/kernel/printk/nbcon.c @@ -1856,7 +1856,7 @@ void nbcon_device_release(struct console *con) if (console_trylock()) console_unlock(); } else if (ft.legacy_offload) { - printk_trigger_flush(); + defer_console_output(); } } console_srcu_read_unlock(cookie); diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index e850c237b4ba..b1c0d35cf3ca 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -4595,9 +4595,30 @@ void defer_console_output(void) __wake_up_klogd(PRINTK_PENDING_WAKEUP | PRINTK_PENDING_OUTPUT); } +/** + * printk_trigger_flush - Attempt to flush printk buffer to consoles. + * + * If possible, flush the printk buffer to all consoles in the caller's + * context. If offloading is available, trigger deferred printing. + * + * This is best effort. Depending on the system state, console states, + * and caller context, no actual flushing may result from this call. + */ void printk_trigger_flush(void) { - defer_console_output(); + struct console_flush_type ft; + + printk_get_console_flush_type(&ft); + if (ft.nbcon_atomic) + nbcon_atomic_flush_pending(); + if (ft.nbcon_offload) + nbcon_kthreads_wake(); + if (ft.legacy_direct) { + if (console_trylock()) + console_unlock(); + } + if (ft.legacy_offload) + defer_console_output(); } int vprintk_deferred(const char *fmt, va_list args) |
