From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B98B813B293 for ; Wed, 7 Jan 2026 23:10:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767827427; cv=none; b=uVQFkgIEaa5FcjHMgz2ATipO9WrF7PqXnR8sk5pWEDfbjPTHbWpC/6lxyj4MtonahIlzO9ym9InqZKkrxQbZPRHkZgOTaL6i5O7I6cVxdDpr6DQj3ptg86Y9PfVgSeaaXUXLmBU9q6UOe9lIbiq95AddZhqXHwhqAXe02EWsXkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767827427; c=relaxed/simple; bh=WrNXVfyKQuV4wiw4dAAcF4yld4HxnoIiUiLSABhXs44=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=NP7ulX8DHOEb+W3r5TEndWgIlhIOKee/gwRL0+0NAtp3rXaA1WOMTUnCiSJKJmHLNlawFloP5fyjc+YHp60m2SfB4QOSJj6vTnYvGdQVc0qhfOoLj751XAVUBiMN6qCY4+eo+bvnVKC5E1z60w0/fNveEG60SVH4tLHz0IaLNVk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=hQ7EjL53; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="hQ7EjL53" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8C3CC4CEF1; Wed, 7 Jan 2026 23:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1767827427; bh=WrNXVfyKQuV4wiw4dAAcF4yld4HxnoIiUiLSABhXs44=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hQ7EjL53P35Yv0tClPEF8hA53dWhtA+Q0RzmIuc+bRO59n4qLkXF1qAeP4oc3pf0k 9Nu3JGUkSf7STNVWqGrpzf/BqzEFY+q/omdccXRTF3vKrFE9wVjzKHlrX5C/aAwV5i 3HUxShphYfML3aAGN6rnH/aBlwO5VzVK7bWLPUEs= Date: Wed, 7 Jan 2026 15:10:26 -0800 From: Andrew Morton To: Pnina Feder Cc: pmladek@suse.com, bhe@redhat.com, linux-kernel@vger.kernel.org, lkp@intel.com, mgorman@suse.de, mingo@redhat.com, peterz@infradead.org, rostedt@goodmis.org, senozhatsky@chromium.org, tglx@linutronix.de, vkondra@mobileye.com Subject: Re: [PATCH v4] panic: add panic_force_cpu= parameter to redirect panic to a specific CPU Message-Id: <20260107151026.6f15603c566c3cc45d9c4852@linux-foundation.org> In-Reply-To: <20260107215659.3619730-1-pnina.feder@mobileye.com> References: <20260105081808.1771473-1-pnina.feder@mobileye.com> <20260107215659.3619730-1-pnina.feder@mobileye.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 7 Jan 2026 23:56:59 +0200 Pnina Feder 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)