[PATCH v2 4/4] sched/topology: Do not clear SD_PREFER_SIBLING in domains with clusters

From: Ricardo Neri

Date: Wed Apr 29 2026 - 17:23:23 EST


Some topologies have scheduling domains that contain CPUs of asymmetric
capacity, grouped into two or more clusters of equal-capacity CPUs
sharing an L2 cache. When CONFIG_SCHED_CLUSTER is enabled, load must be
balanced across these resource-sharing clusters.

Do not clear the SD_PREFER_SIBLING in the child domains to indicate to
the load balancer that it should spread load among cluster siblings.

Checks for capacity in the load balancer will prevent migrations from
high- to low-capacity CPUs. Likewise, misfit load will still be used to
move high-utilization tasks to bigger CPUs.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon@xxxxxxxxxxxxxxx>
---
Changes since v1:
* Reworded the patch description for clarity.
* Kept parentheses around bitwise operators for clarity.
---
kernel/sched/topology.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 5847b83d9d55..78ffc1b8eaff 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1723,8 +1723,15 @@ sd_init(struct sched_domain_topology_level *tl,
/*
* Convert topological properties into behaviour.
*/
- /* Don't attempt to spread across CPUs of different capacities. */
- if ((sd->flags & SD_ASYM_CPUCAPACITY) && sd->child)
+ /*
+ * Don't attempt to spread across CPUs of different capacities. An
+ * exception to this rule are domains in which there are clusters of
+ * CPUs sharing a resource. Keep the flag in such case to balance load
+ * among them. The load balancer will prevent task migrations from
+ * high- to low-capacity CPUs.
+ */
+ if ((sd->flags & SD_ASYM_CPUCAPACITY) && sd->child &&
+ !(sd->child->flags & SD_CLUSTER))
sd->child->flags &= ~SD_PREFER_SIBLING;

if (sd->flags & SD_SHARE_CPUCAPACITY) {

--
2.43.0