Skip to content

Commit

Permalink
x86/mtrr: Avoid repeated save of MTRRs on boot-time CPU bringup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dwmw2 authored and paulmckrcu committed Feb 1, 2023
1 parent 5d245bc commit c39a384
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions arch/x86/kernel/cpu/mtrr/mtrr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c39a384

Please sign in to comment.