Re: [PATCH v6 6/6] panic: kill the "buffer unavailable" redirect fallback

From: Petr Mladek

Date: Tue Aug 25 2026 - 05:49:58 EST


On Tue 2026-08-18 16:38:06, Bradley Morgan wrote:
> The redirect buffer is a disgusting terrible hack. panic_force_buf is
> kmalloc'ed in a late_initcall, the return value is not even checked,

It is not checked intentionally. kmalloc() prints a debug message
on its own when it is not able to allocate the memory.
And it returns NULL in this case. It is enough in this case.

Please, remove this sentence from the commit message.

> and until then the redirect delivers this as the panic message:

> Redirected panic (buffer unavailable)
>
> The whole point of the redirect is to hand the panic message to the
> target CPU, so the crash kernel boots knowing it panicked and not why.
> And that window is the entire boot, from the early_param to the
> late_initcall, which is exactly when you most want the message. A
> failed kmalloc just keeps it broken forever, silently.
>
> Make it a static 1KB buffer and kill the initcall. The cost is 1KB of
> .bss in SMP crash dump builds, and it is only ever touched when
> panic_force_cpu= is set anyway.
>
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -413,20 +403,12 @@ static bool panic_try_force_cpu(const char *fmt, va_list args)
> return old_cpu != this_cpu;
>
> /*
> - * Use dynamically allocated buffer if available, otherwise
> - * fall back to static message for early boot panics or allocation failure.
> + * Do not consume args, the caller reuses them if we fail.
> */
> - if (panic_force_buf) {
> - va_list ap;
> -
> - /* Do not consume args, the caller reuses it if we fail */
> - va_copy(ap, args);
> - vsnprintf(panic_force_buf, PANIC_MSG_BUFSZ, fmt, ap);
> - va_end(ap);
> - msg = panic_force_buf;
> - } else {
> - msg = "Redirected panic (buffer unavailable)";
> - }
> + va_copy(ap, args);
> + vsnprintf(panic_force_buf, PANIC_MSG_BUFSZ, fmt, ap);
> + va_end(ap);
> + msg = panic_force_buf;

Nit: The "msg" variable is no longer needed. It will always be set to
panic_force_buf. The later code could use:

panic_smp_redirect_cpu(panic_force_cpu, (void *)panic_force_buf)

Otherwise, the change looks good from my POV.

Best Regards,
Petr