lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z_khOuvPGEWBAQbp@pathway.suse.cz>
Date: Fri, 11 Apr 2025 16:03:38 +0200
From: Petr Mladek <pmladek@...e.com>
To: carlos.bilbao@...nel.org
Cc: tglx@...utronix.de, bilbao@...edu, akpm@...ux-foundation.org,
	jan.glauber@...il.com, jani.nikula@...el.com,
	linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org,
	takakura@...inux.co.jp, john.ogness@...utronix.de,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Jiri Slaby <jirislaby@...nel.org>
Subject: Re: [PATCH 1/2] panic: Allow archs to reduce CPU consumption after
 panic

Added Linus and Jiri (tty) into Cc.

On Wed 2025-03-26 10:12:03, carlos.bilbao@...nel.org wrote:
> From: Carlos Bilbao <carlos.bilbao@...nel.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@...nel.org>
> Reviewed-by: Jan Glauber (DigitalOcean) <jan.glauber@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ