Skip to content

Commit 4ca234a

Browse files
srikardmpe
authored andcommitted
powerpc/smp: Stop updating cpu_core_mask
Anton Blanchard reported that his 4096 vcpu KVM guest took around 30 minutes to boot. He also analyzed it to the time taken to iterate while setting the cpu_core_mask. Further analysis shows that cpu_core_mask and cpu_cpu_mask for any CPU would be equal on Power. However updating cpu_core_mask took forever to update as its a per cpu cpumask variable. Instead cpu_cpu_mask was a per NODE /per DIE cpumask that was shared by all the respective CPUs. Also cpu_cpu_mask is needed from a scheduler perspective. However cpu_core_map is an exported symbol. Hence stop updating cpu_core_map and make it point to cpu_cpu_mask. Signed-off-by: Srikar Dronamraju <[email protected]> Tested-by: Satheesh Rajendran <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4bce545 commit 4ca234a

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

arch/powerpc/include/asm/smp.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ static inline struct cpumask *cpu_sibling_mask(int cpu)
121121
return per_cpu(cpu_sibling_map, cpu);
122122
}
123123

124-
static inline struct cpumask *cpu_core_mask(int cpu)
125-
{
126-
return per_cpu(cpu_core_map, cpu);
127-
}
128-
129124
static inline struct cpumask *cpu_l2_cache_mask(int cpu)
130125
{
131126
return per_cpu(cpu_l2_cache_map, cpu);

arch/powerpc/kernel/smp.c

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -953,12 +953,17 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
953953
local_memory_node(numa_cpu_lookup_table[cpu]));
954954
}
955955
#endif
956+
/*
957+
* cpu_core_map is now more updated and exists only since
958+
* its been exported for long. It only will have a snapshot
959+
* of cpu_cpu_mask.
960+
*/
961+
cpumask_copy(per_cpu(cpu_core_map, cpu), cpu_cpu_mask(cpu));
956962
}
957963

958964
/* Init the cpumasks so the boot CPU is related to itself */
959965
cpumask_set_cpu(boot_cpuid, cpu_sibling_mask(boot_cpuid));
960966
cpumask_set_cpu(boot_cpuid, cpu_l2_cache_mask(boot_cpuid));
961-
cpumask_set_cpu(boot_cpuid, cpu_core_mask(boot_cpuid));
962967

963968
if (has_coregroup_support())
964969
cpumask_set_cpu(boot_cpuid, cpu_coregroup_mask(boot_cpuid));
@@ -1260,9 +1265,7 @@ static void remove_cpu_from_masks(int cpu)
12601265
{
12611266
int i;
12621267

1263-
/* NB: cpu_core_mask is a superset of the others */
1264-
for_each_cpu(i, cpu_core_mask(cpu)) {
1265-
set_cpus_unrelated(cpu, i, cpu_core_mask);
1268+
for_each_cpu(i, cpu_cpu_mask(cpu)) {
12661269
set_cpus_unrelated(cpu, i, cpu_l2_cache_mask);
12671270
set_cpus_unrelated(cpu, i, cpu_sibling_mask);
12681271
if (has_big_cores)
@@ -1312,15 +1315,13 @@ EXPORT_SYMBOL_GPL(get_physical_package_id);
13121315
static void add_cpu_to_masks(int cpu)
13131316
{
13141317
int first_thread = cpu_first_thread_sibling(cpu);
1315-
int pkg_id = get_physical_package_id(cpu);
13161318
int i;
13171319

13181320
/*
13191321
* This CPU will not be in the online mask yet so we need to manually
13201322
* add it to it's own thread sibling mask.
13211323
*/
13221324
cpumask_set_cpu(cpu, cpu_sibling_mask(cpu));
1323-
cpumask_set_cpu(cpu, cpu_core_mask(cpu));
13241325

13251326
for (i = first_thread; i < first_thread + threads_per_core; i++)
13261327
if (cpu_online(i))
@@ -1342,26 +1343,6 @@ static void add_cpu_to_masks(int cpu)
13421343
set_cpus_related(cpu, i, cpu_coregroup_mask);
13431344
}
13441345
}
1345-
1346-
if (pkg_id == -1) {
1347-
struct cpumask *(*mask)(int) = cpu_sibling_mask;
1348-
1349-
/*
1350-
* Copy the sibling mask into core sibling mask and
1351-
* mark any CPUs on the same chip as this CPU.
1352-
*/
1353-
if (shared_caches)
1354-
mask = cpu_l2_cache_mask;
1355-
1356-
for_each_cpu(i, mask(cpu))
1357-
set_cpus_related(cpu, i, cpu_core_mask);
1358-
1359-
return;
1360-
}
1361-
1362-
for_each_cpu(i, cpu_online_mask)
1363-
if (get_physical_package_id(i) == pkg_id)
1364-
set_cpus_related(cpu, i, cpu_core_mask);
13651346
}
13661347

13671348
/* Activate a secondary processor. */

0 commit comments

Comments
 (0)