Commit e0a9ac19 authored by Li RongQing's avatar Li RongQing Committed by Ingo Molnar

x86/cpu: Take NUMA node into account when allocating per-CPU cpumasks

per-CPU cpumasks are dominantly accessed from their own local CPUs,
so allocate them node-local to improve performance.

[ mingo: Rewrote the changelog. ]
Signed-off-by: default avatarLi RongQing <lirongqing@baidu.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20240410030114.6201-1-lirongqing@baidu.com
parent 7911f145
......@@ -183,7 +183,8 @@ static int x2apic_prepare_cpu(unsigned int cpu)
if (alloc_clustermask(cpu, cluster, cpu_to_node(cpu)) < 0)
return -ENOMEM;
if (!zalloc_cpumask_var(&per_cpu(ipi_mask, cpu), GFP_KERNEL))
if (!zalloc_cpumask_var_node(&per_cpu(ipi_mask, cpu), GFP_KERNEL,
cpu_to_node(cpu)))
return -ENOMEM;
return 0;
}
......
......@@ -1033,7 +1033,7 @@ static __init void disable_smp(void)
void __init smp_prepare_cpus_common(void)
{
unsigned int i;
unsigned int i, n;
/* Mark all except the boot CPU as hotpluggable */
for_each_possible_cpu(i) {
......@@ -1042,11 +1042,12 @@ void __init smp_prepare_cpus_common(void)
}
for_each_possible_cpu(i) {
zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL);
zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL);
zalloc_cpumask_var(&per_cpu(cpu_die_map, i), GFP_KERNEL);
zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL);
zalloc_cpumask_var(&per_cpu(cpu_l2c_shared_map, i), GFP_KERNEL);
n = cpu_to_node(i);
zalloc_cpumask_var_node(&per_cpu(cpu_sibling_map, i), GFP_KERNEL, n);
zalloc_cpumask_var_node(&per_cpu(cpu_core_map, i), GFP_KERNEL, n);
zalloc_cpumask_var_node(&per_cpu(cpu_die_map, i), GFP_KERNEL, n);
zalloc_cpumask_var_node(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL, n);
zalloc_cpumask_var_node(&per_cpu(cpu_l2c_shared_map, i), GFP_KERNEL, n);
}
set_cpu_sibling_map(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment