[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260107151026.6f15603c566c3cc45d9c4852@linux-foundation.org>
Date: Wed, 7 Jan 2026 15:10:26 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Pnina Feder <pnina.feder@...ileye.com>
Cc: pmladek@...e.com, bhe@...hat.com, linux-kernel@...r.kernel.org,
lkp@...el.com, mgorman@...e.de, mingo@...hat.com, peterz@...radead.org,
rostedt@...dmis.org, senozhatsky@...omium.org, tglx@...utronix.de,
vkondra@...ileye.com
Subject: Re: [PATCH v4] panic: add panic_force_cpu= parameter to redirect
panic to a specific CPU
On Wed, 7 Jan 2026 23:56:59 +0200 Pnina Feder <pnina.feder@...ileye.com> wrote:
> Some platforms require panic handling to execute on a specific CPU for
> crash dump to work reliably. This can be due to firmware limitations,
> interrupt routing constraints, or platform-specific requirements where
> only a single CPU is able to safely enter the crash kernel.
>
> Add the panic_force_cpu= kernel command-line parameter to redirect panic
> execution to a designated CPU. When the parameter is provided, the CPU
> that initially triggers panic forwards the panic context to the target
> CPU via IPI, which then proceeds with the normal panic and kexec flow.
>
> If the specified CPU is invalid, offline, or a panic is already in
> progress on another CPU, the redirection is skipped and panic continues
> on the current CPU.
>
> Changes since v3:
> - Dump original CPU's stack before redirecting to preserve debug info
> - Add Documentation/admin-guide/kernel-parameters.txt entry
> - Use smp_call_function_single_async() to avoid blocking in csd_lock()
> - Add CONFIG_CRASH_DUMP dependency
> - Reuse vpanic()'s static buffer instead of separate allocation
> - Remove verbose warning messages
Looking nice to my eye.
> +#if defined(CONFIG_SMP) && defined(CONFIG_CRASH_DUMP)
Congrats on caring about uniprocessor ;)
> +/* CPU to redirect panic to, or -1 if disabled */
> +static int panic_force_cpu = -1;
> +static call_single_data_t panic_csd;
> +
> +static int __init panic_force_cpu_setup(char *str)
> +{
> + int cpu;
> +
> + if (!str)
> + return -EINVAL;
> +
> + if (kstrtoint(str, 0, &cpu) || cpu < 0) {
> + pr_warn("panic_force_cpu: invalid value '%s'\n", str);
> + return -EINVAL;
> + }
> +
> + panic_force_cpu = cpu;
> + return 0;
> +}
> +early_param("panic_force_cpu", panic_force_cpu_setup);
> +
> +static void do_panic_on_target_cpu(void *info)
> +{
> + panic("%s", (char *)info);
Probably the (char *) cast isn't needed?
> +}
> +
> +/**
> + * panic_force_target_cpu - Redirect panic to a specific CPU for crash kernel
> + * @fmt: panic message format string
> + * @args: arguments for format string
`make htmldocs' is going to get upset about missing docs for `buf' and
`buf_size'?
> + * Some platforms require panic handling to occur on a specific CPU
> + * for the crash kernel to function correctly. This function redirects
> + * panic handling to the CPU specified via the panic_redirect_cpu= boot parameter.
> + *
> + * Returns true if panic should proceed on current CPU.
> + * Returns false (never returns) if panic was redirected.
> + */
> +__printf(3, 0)
> +static bool panic_force_target_cpu(char *buf, int buf_size, const char *fmt, va_list args)
Powered by blists - more mailing lists