Skip to content

Commit 87800a0

Browse files
kudureranganathgregkh
authored andcommitted
sched/topology: Compute sd_weight considering cpuset partitions
[ Upstream commit 8e8e23d ] The "sd_weight" used for calculating the load balancing interval, and its limits, considers the span weight of the entire topology level without accounting for cpuset partitions. For example, consider a large system of 128CPUs divided into 8 * 16CPUs partition which is typical when deploying virtual machines: [ PKG Domain: 128CPUs ] [Partition0: 16CPUs][Partition1: 16CPUs] ... [Partition7: 16CPUs] Although each partition only contains 16CPUs, the load balancing interval is set to a minimum of 128 jiffies considering the span of the entire domain with 128CPUs which can lead to longer imbalances within the partition although balancing within is cheaper with 16CPUs. Compute the "sd_weight" after computing the "sd_span" considering the cpu_map covered by the partition, and set the load balancing interval, and its limits accordingly. For the above example, the balancing intervals for the partitions PKG domain changes as follows: before after balance_interval 128 16 min_interval 128 16 max_interval 256 32 Intervals are now proportional to the CPUs in the partitioned domain as was intended by the original formula. Fixes: cb83b62 ("sched/numa: Rewrite the CONFIG_NUMA sched domain support") Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com> Reviewed-by: Chen Yu <yu.c.chen@intel.com> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Link: https://patch.msgid.link/20260312044434.1974-2-kprateek.nayak@amd.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5fbefcd commit 87800a0

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

kernel/sched/topology.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,13 +1631,17 @@ sd_init(struct sched_domain_topology_level *tl,
16311631
int sd_id, sd_weight, sd_flags = 0;
16321632
struct cpumask *sd_span;
16331633

1634-
sd_weight = cpumask_weight(tl->mask(tl, cpu));
1634+
sd_span = sched_domain_span(sd);
1635+
cpumask_and(sd_span, cpu_map, tl->mask(tl, cpu));
1636+
sd_weight = cpumask_weight(sd_span);
1637+
sd_id = cpumask_first(sd_span);
16351638

16361639
if (tl->sd_flags)
16371640
sd_flags = (*tl->sd_flags)();
16381641
if (WARN_ONCE(sd_flags & ~TOPOLOGY_SD_FLAGS,
1639-
"wrong sd_flags in topology description\n"))
1642+
"wrong sd_flags in topology description\n"))
16401643
sd_flags &= TOPOLOGY_SD_FLAGS;
1644+
sd_flags |= asym_cpu_capacity_classify(sd_span, cpu_map);
16411645

16421646
*sd = (struct sched_domain){
16431647
.min_interval = sd_weight,
@@ -1674,12 +1678,6 @@ sd_init(struct sched_domain_topology_level *tl,
16741678
.name = tl->name,
16751679
};
16761680

1677-
sd_span = sched_domain_span(sd);
1678-
cpumask_and(sd_span, cpu_map, tl->mask(tl, cpu));
1679-
sd_id = cpumask_first(sd_span);
1680-
1681-
sd->flags |= asym_cpu_capacity_classify(sd_span, cpu_map);
1682-
16831681
WARN_ONCE((sd->flags & (SD_SHARE_CPUCAPACITY | SD_ASYM_CPUCAPACITY)) ==
16841682
(SD_SHARE_CPUCAPACITY | SD_ASYM_CPUCAPACITY),
16851683
"CPU capacity asymmetry not supported on SMT\n");

0 commit comments

Comments
 (0)