Skip to content

Commit

Permalink
powerpc/smp: Move coregroup mask updation to a new function
Browse files Browse the repository at this point in the history
Move the logic for updating the coregroup mask of a CPU to its own
function. This will help in reworking the updation of coregroup mask in
subsequent patch.

Signed-off-by: Srikar Dronamraju <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
srikard authored and mpe committed Oct 6, 2020
1 parent 3ab33d6 commit b8a97cb
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions arch/powerpc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,23 @@ static inline void add_cpu_to_smallcore_masks(int cpu)
}
}

static void update_coregroup_mask(int cpu)
{
int first_thread = cpu_first_thread_sibling(cpu);
int coregroup_id = cpu_to_coregroup_id(cpu);
int i;

cpumask_set_cpu(cpu, cpu_coregroup_mask(cpu));
for_each_cpu_and(i, cpu_online_mask, cpu_cpu_mask(cpu)) {
int fcpu = cpu_first_thread_sibling(i);

if (fcpu == first_thread)
set_cpus_related(cpu, i, cpu_coregroup_mask);
else if (coregroup_id == cpu_to_coregroup_id(i))
set_cpus_related(cpu, i, cpu_coregroup_mask);
}
}

static void add_cpu_to_masks(int cpu)
{
int first_thread = cpu_first_thread_sibling(cpu);
Expand All @@ -1355,19 +1372,8 @@ static void add_cpu_to_masks(int cpu)
add_cpu_to_smallcore_masks(cpu);
update_mask_by_l2(cpu);

if (has_coregroup_support()) {
int coregroup_id = cpu_to_coregroup_id(cpu);

cpumask_set_cpu(cpu, cpu_coregroup_mask(cpu));
for_each_cpu_and(i, cpu_online_mask, cpu_cpu_mask(cpu)) {
int fcpu = cpu_first_thread_sibling(i);

if (fcpu == first_thread)
set_cpus_related(cpu, i, cpu_coregroup_mask);
else if (coregroup_id == cpu_to_coregroup_id(i))
set_cpus_related(cpu, i, cpu_coregroup_mask);
}
}
if (has_coregroup_support())
update_coregroup_mask(cpu);
}

/* Activate a secondary processor. */
Expand Down

0 comments on commit b8a97cb

Please sign in to comment.