v1 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 6/6. 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. Changes since v1: - Make console.unsafe_flush_flags unsigned. - Add missing kerneldoc description for printk_trigger_flush(). - Remove the WARN_ON_ONCE() in nbcon_context_try_acquire_hostile() since hostile takeovers are now possible from non-panic contexts. - Also provide a flush reason for console_flush_on_panic(). - Add a global variable @legacy_flush_reason to track reason for legacy flushing. - Explicitly set PR_FLUSH_RUNTIME to 0 since it is now used to initialize @legacy_flush_reason. - Temporarily set @legacy_flush_reason during legacy flushing of console_flush_on_panic() and printk_trigger_flush(). - Also set/check ctxt->allow_unsafe_takeover in nbcon_legacy_emit_next_record() to enforce flush policies for legacy flushing. John Ogness [0] https://lore.kernel.org/lkml/[email protected] [1] https://lore.kernel.org/lkml/[email protected] John Ogness (6): printk: Introduce and specify flush reasons console: Introduce unsafe flush policy flags printk: Evaluate flush policy in nbcon_allow_unsafe_takeover() printk: Remove nbcon_atomic_flush_unsafe() printk: Add panic+kexec flush point netconsole: Always perform unsafe flushing on panic/kdb/restart arch/loongarch/kernel/reset.c | 2 +- arch/powerpc/kernel/traps.c | 2 +- arch/powerpc/kernel/watchdog.c | 2 +- drivers/net/netconsole.c | 4 + include/linux/console.h | 39 +++++++--- include/linux/printk.h | 27 +++++-- kernel/crash_core.c | 1 + kernel/debug/debug_core.c | 2 +- kernel/panic.c | 8 +- kernel/printk/internal.h | 5 +- kernel/printk/nbcon.c | 129 ++++++++++++++++++++++----------- kernel/printk/printk.c | 38 +++++++--- kernel/reboot.c | 2 +- lib/nmi_backtrace.c | 2 +- 14 files changed, 181 insertions(+), 82 deletions(-) base-commit: d01f86a7da8161aac8c6304b377cf58fb75861ca -- 2.47.3
