Re: [RFC PATCH v1] panic: Flush unsafe consoles before panic reboot

From: John Ogness

Date: Tue Oct 27 2026 - 14:03:23 EST


On 2026-10-27, Breno Leitao <leitao@xxxxxxxxxx> wrote:
> On Tue, Oct 27, 2026 at 09:12:09AM -0700, Breno Leitao wrote:
>> So netconsole, or any CON_NBCON_ATOMIC_UNSAFE console, prints nothing
>> on kdump hosts.
>
> For flushing unsafe on nbcon on hosts with kdump environment, this seems
> to do the work, but, maybe this is too unsafe !?

For the general case, it is certainly too unsafe. As I suggested [0] we
need a way to allows users to make this decision. nbcon was designed to
allow for printing policies, but we have not yet provided the interfaces
for the user specify such policies nor the mechanism to enforce the
policies.

Perhaps we need to begin by identifying all the sites where the current
kernel is ending (whether reboot, shutdown, panic, kexec, hang).

> diff --git a/kernel/crash_core.c b/kernel/crash_core.c
> index d0bd2d0cf8990b..9f1a89e301ff01 100644
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
> @@ -140,6 +140,8 @@ void __noclone __crash_kexec(struct pt_regs *regs)
>
> crash_setup_regs(&fixed_regs, regs);
> crash_save_vmcoreinfo();
> + /* Flush consoles with an unsafe write_atomic(), e.g. netconsole. */
> + nbcon_atomic_flush_unsafe();

I am guessing that the CPU is _always_ in emergency state here?
Otherwise the flushing problem exists for all atomic consoles.

> machine_crash_shutdown(&fixed_regs);
> crash_cma_clear_pending_dma();
> machine_kexec(kexec_crash_image);
>

John

[0] https://lore.kernel.org/lkml/87bj8kkfwk.fsf@xxxxxxxxxxxxxxxxxxxxx/