Skip to content

Commit

Permalink
arm64: topology: restrict updating siblings_masks to online cpus only
Browse files Browse the repository at this point in the history
It's incorrect to iterate over all the possible CPUs to update the
sibling masks when any CPU is hotplugged in. In case the topology
siblings masks of the CPU is removed when is it hotplugged out, we
end up updating those masks when one of it's sibling is powered up
again. This will provide inconsistent view.

Further, since the CPU calling update_sibling_masks is yet to be set
online, there's no need to compare itself with each online CPU when
updating the siblings masks.

This patch restricts updation of sibling masks only for CPUs that are
already online. It also the drops the unnecessary cpuid check.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Tested-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
Tested-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
  • Loading branch information
Sudeep Holla authored and Will Deacon committed Jul 6, 2018
1 parent 5bdd2b3 commit 5ec8b59
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions arch/arm64/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void update_siblings_masks(unsigned int cpuid)
int cpu;

/* update core and thread sibling masks */
for_each_possible_cpu(cpu) {
for_each_online_cpu(cpu) {
cpu_topo = &cpu_topology[cpu];

if (cpuid_topo->llc_id == cpu_topo->llc_id) {
Expand All @@ -243,15 +243,13 @@ static void update_siblings_masks(unsigned int cpuid)
continue;

cpumask_set_cpu(cpuid, &cpu_topo->core_sibling);
if (cpu != cpuid)
cpumask_set_cpu(cpu, &cpuid_topo->core_sibling);
cpumask_set_cpu(cpu, &cpuid_topo->core_sibling);

if (cpuid_topo->core_id != cpu_topo->core_id)
continue;

cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling);
if (cpu != cpuid)
cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling);
cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling);
}
}

Expand Down

0 comments on commit 5ec8b59

Please sign in to comment.