[PATCH v2 3/6] sched/fair: Only count group weight for CPUs doing load balance when looking for src group

From: Adam Li
Date: Thu Jul 17 2025 - 02:22:13 EST


Load balancing is limitted to a set of CPUs, such as active CPUs.
Group classification may be incorrect if group weight counts inactive CPUs.

Signed-off-by: Adam Li <adamli@xxxxxxxxxxxxxxxxxxxxxx>
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 452e2df961b9..db9ec6a6acdf 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10427,7 +10427,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,

sgs->group_capacity = group->sgc->capacity;

- sgs->group_weight = group->group_weight;
+ sgs->group_weight = cpumask_weight_and(sched_group_span(group), env->cpus);

/* Check if dst CPU is idle and preferred to this group */
if (!local_group && env->idle && sgs->sum_h_nr_running &&
--
2.34.1