From: David Woodhouse Date: Tue, 14 Dec 2021 14:49:11 +0000 (+0000) Subject: x86/mtrr: Avoid repeated save of MTRRs on boot-time CPU bringup X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=cc3e777e83a680bd1eb3fb583ee4c0af0e2b8c7e;p=users%2Fdwmw2%2Flinux.git x86/mtrr: Avoid repeated save of MTRRs on boot-time CPU bringup There's no need to repeatedly save the BSP's MTRRs for each AP we bring up at boot time. And there's no need to use smp_call_function_single() even for the one time we *do* want to do it. Signed-off-by: David Woodhouse --- diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c index 2746cac9d8a94..2884017586f1e 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.c +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c @@ -814,11 +814,20 @@ void mtrr_ap_init(void) */ void mtrr_save_state(void) { + static bool mtrr_saved; int first_cpu; if (!mtrr_enabled()) return; + if (system_state < SYSTEM_RUNNING) { + if (!mtrr_saved) { + mtrr_save_fixed_ranges(NULL); + mtrr_saved = true; + } + return; + } + first_cpu = cpumask_first(cpu_online_mask); smp_call_function_single(first_cpu, mtrr_save_fixed_ranges, NULL, 1); }