Skip to content

Commit d24cb0d

Browse files
pdxChenPeter Zijlstra
authored andcommitted
sched/topology: Record number of cores in sched group
When balancing sibling domains that have different number of cores, tasks in respective sibling domain should be proportional to the number of cores in each domain. In preparation of implementing such a policy, record the number of cores in a scheduling group. Signed-off-by: Tim Chen <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/04641eeb0e95c21224352f5743ecb93dfac44654.1688770494.git.tim.c.chen@linux.intel.com
1 parent fee1759 commit d24cb0d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

kernel/sched/sched.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,7 @@ struct sched_group {
18841884
atomic_t ref;
18851885

18861886
unsigned int group_weight;
1887+
unsigned int cores;
18871888
struct sched_group_capacity *sgc;
18881889
int asym_prefer_cpu; /* CPU of highest priority in group */
18891890
int flags;

kernel/sched/topology.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,14 +1275,24 @@ build_sched_groups(struct sched_domain *sd, int cpu)
12751275
static void init_sched_groups_capacity(int cpu, struct sched_domain *sd)
12761276
{
12771277
struct sched_group *sg = sd->groups;
1278+
struct cpumask *mask = sched_domains_tmpmask2;
12781279

12791280
WARN_ON(!sg);
12801281

12811282
do {
1282-
int cpu, max_cpu = -1;
1283+
int cpu, cores = 0, max_cpu = -1;
12831284

12841285
sg->group_weight = cpumask_weight(sched_group_span(sg));
12851286

1287+
cpumask_copy(mask, sched_group_span(sg));
1288+
for_each_cpu(cpu, mask) {
1289+
cores++;
1290+
#ifdef CONFIG_SCHED_SMT
1291+
cpumask_andnot(mask, mask, cpu_smt_mask(cpu));
1292+
#endif
1293+
}
1294+
sg->cores = cores;
1295+
12861296
if (!(sd->flags & SD_ASYM_PACKING))
12871297
goto next;
12881298

0 commit comments

Comments
 (0)