Skip to content

Commit a32226f

Browse files
KAGA-KOKOPeter Zijlstra
authored andcommitted
x86/cpu/cacheinfo: Remove cpu_callout_mask dependency
cpu_callout_mask is used for the stop machine based MTRR/PAT init. In preparation of moving the BP/AP synchronization to the core hotplug code, use a private CPU mask for cacheinfo and manage it in the starting/dying hotplug state. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Michael Kelley <[email protected]> Tested-by: Oleksandr Natalenko <[email protected]> Tested-by: Helge Deller <[email protected]> # parisc Tested-by: Guilherme G. Piccoli <[email protected]> # Steam Deck Link: https://lore.kernel.org/r/[email protected]
1 parent e94cd15 commit a32226f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

arch/x86/kernel/cpu/cacheinfo.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
3939
/* Shared L2 cache maps */
4040
DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_l2c_shared_map);
4141

42+
static cpumask_var_t cpu_cacheinfo_mask;
43+
4244
/* Kernel controls MTRR and/or PAT MSRs. */
4345
unsigned int memory_caching_control __ro_after_init;
4446

@@ -1172,8 +1174,10 @@ void cache_bp_restore(void)
11721174
cache_cpu_init();
11731175
}
11741176

1175-
static int cache_ap_init(unsigned int cpu)
1177+
static int cache_ap_online(unsigned int cpu)
11761178
{
1179+
cpumask_set_cpu(cpu, cpu_cacheinfo_mask);
1180+
11771181
if (!memory_caching_control || get_cache_aps_delayed_init())
11781182
return 0;
11791183

@@ -1191,11 +1195,17 @@ static int cache_ap_init(unsigned int cpu)
11911195
* lock to prevent MTRR entry changes
11921196
*/
11931197
stop_machine_from_inactive_cpu(cache_rendezvous_handler, NULL,
1194-
cpu_callout_mask);
1198+
cpu_cacheinfo_mask);
11951199

11961200
return 0;
11971201
}
11981202

1203+
static int cache_ap_offline(unsigned int cpu)
1204+
{
1205+
cpumask_clear_cpu(cpu, cpu_cacheinfo_mask);
1206+
return 0;
1207+
}
1208+
11991209
/*
12001210
* Delayed cache initialization for all AP's
12011211
*/
@@ -1210,9 +1220,12 @@ void cache_aps_init(void)
12101220

12111221
static int __init cache_ap_register(void)
12121222
{
1223+
zalloc_cpumask_var(&cpu_cacheinfo_mask, GFP_KERNEL);
1224+
cpumask_set_cpu(smp_processor_id(), cpu_cacheinfo_mask);
1225+
12131226
cpuhp_setup_state_nocalls(CPUHP_AP_CACHECTRL_STARTING,
12141227
"x86/cachectrl:starting",
1215-
cache_ap_init, NULL);
1228+
cache_ap_online, cache_ap_offline);
12161229
return 0;
12171230
}
1218-
core_initcall(cache_ap_register);
1231+
early_initcall(cache_ap_register);

0 commit comments

Comments
 (0)