From 0989cc288e8974e94ba5f0e9230c381212a53b45 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 7 Feb 2023 23:04:35 +0000 Subject: [PATCH] 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 being brought up at boot time. And no need to use smp_call_function_single() even for the one time they do need to be saved. Signed-off-by: David Woodhouse Signed-off-by: Usama Arif Signed-off-by: Paul E. McKenney --- arch/x86/kernel/cpu/mtrr/mtrr.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c index 783f3210d5827e..b6eae3ad4414bf 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.c +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c @@ -721,11 +721,20 @@ void __init mtrr_bp_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); }