Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by John Ogness
Wed, 18 Nov 2026 23:03
[PATCH printk v3 0/7] Introduce policies for unsafe flushing
Author: John Ogness
Date: Wed, 18 Nov 2026 23:03
Date: Wed, 18 Nov 2026 23:03
90 lines
13484 bytes
13484 bytes
v2 is here [0]. Until now unsafe flushing is only performed at the very end of panic(), before entering the infinite loop. For other situations (such as panic-kexec or panic-reboot or emergency-reboot) no unsafe flushing is performed. The reasoning for this is because an unsafe flush could lead to fireworks, which could prevent the kexec or reboot from occurring. However, some users may be willing to take on such risks in order to see panic output. Indeed, for the netconsole (which does not support safe atomic printing) it is a regression that such unsafe printing does not occur. [1] This series adds unsafe flushing policy flags per-console to allow individual consoles to perform unsafe flushing for such scenarios. The unsafe flushing is hard-code-enabled for the netconsole in patch 7/7. The justification is that this is not less safe than the legacy netconsole. Later these policy flags could be easily exposed to userspace via /sys/class/consoles/, once the sysfs per-console interface is available. For this version I reduced the unsafe flush policies to the minimum required by the netconsole: panic+restart and emergency+restart. I also keep nbcon_atomic_flush_unsafe() and use only this function for specifying the flush reasons. This allows us to pinpoint where unsafe flushing is evaluated and, as a nice bonus, to avoid all the legacy madness. The first 4 patches have no functional changes. Hopefully they are each small enough that a review is relatively trivial. The functional changes (5-7) are also compact. Changes since v2: - Specify flush reason in nbcon_atomic_flush_unsafe() instead of console_flush_on_panic() and printk_trigger_flush(). This automatically avoids the need for any legacy handling. - Remove KDB, PRINTK, NOTHREAD unsafe flush policies. (Not needed for now.) - Add EMERGENCY_RESTART unsafe flush policy to be used for emergency_restart() when non-panic. - Rename console.unsafe_flush_flags to console.allow_unsafe_policy. - Change console_is_usable() to _never_ report CON_NBCON_ATOMIC_UNSAFE as usable. - Introduce nbcon_is_unsafe_usable() as a variant to console_is_usable() to report CON_NBCON_ATOMIC_UNSAFE as usable. The caller decides if unsafe printing should occur. This is only used for nbcon+atomic flushing. - Perform unsafe flush policy check higher up in __nbcon_atomic_flush_pending() instead of __nbcon_atomic_flush_pending_con(). John Ogness [0] https://lore.kernel.org/lkml/20261111181942.593695-1-john.ogness@linutronix.de [1] https://lore.kernel.org/lkml/20260915100140.3631650-1-ryan.roberts@arm.com John Ogness (7): printk: Introduce and specify flush reasons printk: nbcon: Move unsafe takeover check to higher level printk: Move unsafe takeover check out of console_is_usable() printk: Use @reason instead of global variable to check flush policy console: Support unsafe flushing for panic/emergency restarts printk: Add unsafe flush points for panic+kexec and emergency_restart netconsole: Perform unsafe flushing on panic and emergency restart drivers/net/netconsole.c | 2 + include/linux/console.h | 60 ++++++++++++++++++++------ include/linux/printk.h | 20 ++++++++- kernel/crash_core.c | 1 + kernel/panic.c | 2 +- kernel/printk/nbcon.c | 91 +++++++++++++++++++++++++++------------- kernel/reboot.c | 1 + 7 files changed, 131 insertions(+), 46 deletions(-) base-commit: ef19063ad84f8ed58ee44ebd49ba035fd5159e74 -- 2.47.3
[PATCH printk v3 7/7] netconsole: Perform unsafe flushing on panic and emergency restart
Author: John Ogness
Date: Wed, 18 Nov 2026 23:03
Date: Wed, 18 Nov 2026 23:03
38 lines
11023 bytes
11023 bytes
As a legacy console the netconsole would perform unsafe flushing
during panic and emergency restart. With commit 7eab73b18630
("netconsole: convert to NBCON console infrastructure") the netconsole
is now an NBCON console, however it uses the CON_NBCON_ATOMIC_UNSAFE
flag and this prevents unsafe flushing except for at the very end of
panic().
Enable default unsafe flushing policies to allow the netconsole to
perform unsafe flushing during panic and emergency restart.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
drivers/net/netconsole.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 267254f046de9..3300b2bbbd413 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -2695,6 +2695,7 @@ static void free_param_target(struct netconsole_target *nt)
static struct console netconsole_ext = {
.name = "netcon_ext",
.flags = CON_ENABLED | CON_EXTENDED | CON_NBCON | CON_NBCON_ATOMIC_UNSAFE,
+ .allow_unsafe_policy = NBCON_PANIC_RESTART_FLUSH | NBCON_EMERGENCY_RESTART_FLUSH,
.write_thread = netconsole_write_ext,
.write_atomic = netconsole_write_ext,
.device_lock = netconsole_device_lock,
@@ -2704,6 +2705,7 @@ static struct console netconsole_ext = {
static struct console netconsole = {
.name = "netcon",
.flags = CON_ENABLED | CON_NBCON | CON_NBCON_ATOMIC_UNSAFE,
+ .allow_unsafe_policy = NBCON_PANIC_RESTART_FLUSH | NBCON_EMERGENCY_RESTART_FLUSH,
.write_thread = netconsole_write_basic,
.write_atomic = netconsole_write_basic,
.device_lock = netconsole_device_lock,
--
2.47.3
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads