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] [day] [month] [year] [list]
Message-ID: <20250326151204.67898-2-carlos.bilbao@kernel.org>
Date: Wed, 26 Mar 2025 10:12:03 -0500
From: carlos.bilbao@...nel.org
To: tglx@...utronix.de
Cc: bilbao@...edu,
	pmladek@...e.com,
	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,
	Carlos Bilbao <carlos.bilbao@...nel.org>
Subject: [PATCH 1/2] panic: Allow archs to reduce CPU consumption after panic

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();
 	}
 }
 
-- 
2.47.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ