]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/mtrr: Avoid repeated save of MTRRs on boot-time CPU bringup
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 1 Feb 2023 20:43:37 +0000 (20:43 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Sat, 4 Feb 2023 15:32:26 +0000 (15:32 +0000)
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 <dwmw@amazon.co.uk>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
arch/x86/kernel/cpu/mtrr/mtrr.c

index 783f3210d5827ecf68e5a9b97eb0a869539a9de6..b6eae3ad4414bf28111387f338aefb70e2e94d4b 100644 (file)
@@ -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);
 }