From: Petr Mladek <pmladek@suse.com>
To: carlos.bilbao@kernel.org
Cc: tglx@linutronix.de, bilbao@vt.edu, akpm@linux-foundation.org,
jan.glauber@gmail.com, jani.nikula@intel.com,
linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
takakura@valinux.co.jp, john.ogness@linutronix.de,
Linus Torvalds <torvalds@linux-foundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Subject: Re: [PATCH 1/2] panic: Allow archs to reduce CPU consumption after panic
Date: Fri, 11 Apr 2025 16:03:38 +0200 [thread overview]
Message-ID: <Z_khOuvPGEWBAQbp@pathway.suse.cz> (raw)
In-Reply-To: <20250326151204.67898-2-carlos.bilbao@kernel.org>
Added Linus and Jiri (tty) into Cc.
On Wed 2025-03-26 10:12:03, carlos.bilbao@kernel.org wrote:
> From: Carlos Bilbao <carlos.bilbao@kernel.org>
>
> After handling a panic, the kernel enters a busy-wait loop, unnecessarily
> consuming CPU and potentially impacting other workloads including other
> guest VMs in the case of virtualized setups.
>
> Introduce cpu_halt_after_panic(), a weak function that archs can override
> for a more efficient halt of CPU work. By default, it preserves the
> pre-existing behavior of delay.
>
> Signed-off-by: Carlos Bilbao (DigitalOcean) <carlos.bilbao@kernel.org>
> Reviewed-by: Jan Glauber (DigitalOcean) <jan.glauber@gmail.com>
> ---
> kernel/panic.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/panic.c b/kernel/panic.c
> index fbc59b3b64d0..fafe3fa22533 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -276,6 +276,16 @@ static void panic_other_cpus_shutdown(bool crash_kexec)
> crash_smp_send_stop();
> }
>
> +/*
> + * Called after a kernel panic has been handled, at which stage halting
> + * the CPU can help reduce unnecessary CPU consumption. In the absence of
> + * arch-specific implementations, just delay
> + */
> +static void __weak cpu_halt_after_panic(void)
> +{
> + mdelay(PANIC_TIMER_STEP);
> +}
> +
> /**
> * panic - halt the system
> * @fmt: The text string to print
> @@ -474,7 +484,7 @@ void panic(const char *fmt, ...)
> i += panic_blink(state ^= 1);
> i_next = i + 3600 / PANIC_BLINK_SPD;
> }
> - mdelay(PANIC_TIMER_STEP);
> + cpu_halt_after_panic();
The 2nd patch implements this functions using safe_halt().
IMHO, it makes perfect sense to halt a virtualized system or
a system without a registered "graphical" console.
I think that the blinking diods were designed for desktops
and laptops with some "graphical" terminal attached. The
infinite loop allows to read the last lines, ideally
the backtrace on the screen.
I wonder if we could make it more clever and do the halt
only when the system is virtualized or when there is no
"graphical" console registered.
One way to detect graphical console might a check of
the existence of the c->unblank callback, see console_unblank().
But I am not sure if it is good enough.
Best Regards,
Petr
next prev parent reply other threads:[~2025-04-11 14:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 15:12 [PATCH 0/2] Reduce CPU usage when finished handling panic carlos.bilbao
2025-03-26 15:12 ` [PATCH 1/2] panic: Allow archs to reduce CPU consumption after panic carlos.bilbao
2025-04-11 14:03 ` Petr Mladek [this message]
2025-04-11 16:31 ` Sean Christopherson
2025-04-14 10:02 ` Jan Glauber
2025-04-22 12:44 ` Carlos Bilbao
2025-03-26 15:12 ` [PATCH 2/2] x86/panic: Use safe_halt() for CPU halt " carlos.bilbao
2025-04-10 17:30 ` Reminder: [PATCH 0/2] Reduce CPU usage when finished handling panic Carlos Bilbao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z_khOuvPGEWBAQbp@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=bilbao@vt.edu \
--cc=carlos.bilbao@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jan.glauber@gmail.com \
--cc=jani.nikula@intel.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=takakura@valinux.co.jp \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.