[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <f2272f04-510e-4c92-be5e-fedcbb445eb0@gmail.com>
Date: Mon, 17 Mar 2025 17:01:22 -0500
From: Carlos Bilbao <carlos.bilbao.osdev@...il.com>
To: pmladek@...e.com, Andrew Morton <akpm@...ux-foundation.org>,
jani.nikula@...el.com, open list <linux-kernel@...r.kernel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Thomas Gleixner <tglx@...utronix.de>, takakura@...inux.co.jp,
john.ogness@...utronix.de
Subject: [RFC] panic: reduce CPU consumption when finished handling panic
After the kernel has finished handling a panic, it enters a busy-wait loop.
But, this unnecessarily consumes CPU power and electricity. Plus, in VMs,
this negatively impacts the throughput of other VM guests running on the
same hypervisor.
I propose introducing a function cpu_halt_end_panic() to halt the CPU
during this state while still allowing interrupts to be processed. See my
commit below.
Thanks in advance!
Signed-off-by: Carlos Bilbao <carlos.bilbao@...nel.org>
---
kernel/panic.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/kernel/panic.c b/kernel/panic.c
index fbc59b3b64d0..c00ccaa698d5 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -276,6 +276,21 @@ static void panic_other_cpus_shutdown(bool crash_kexec)
crash_smp_send_stop();
}
+static void cpu_halt_end_panic(void)
+{
+#ifdef CONFIG_X86
+ native_safe_halt();
+#elif defined(CONFIG_ARM)
+ cpu_do_idle();
+#else
+ /*
+ * Default to a simple busy-wait if no architecture-specific halt is
+ * defined above
+ */
+ mdelay(PANIC_TIMER_STEP);
+#endif
+}
+
/**
* panic - halt the system
* @fmt: The text string to print
@@ -474,7 +489,7 @@ void panic(const char *fmt, ...)
i += panic_blink(state ^= 1);
i_next = i + 3600 / PANIC_BLINK_SPD;
}
- mdelay(PANIC_TIMER_STEP);
+ cpu_halt_end_panic();
}
}
--
2.47.1
Powered by blists - more mailing lists