Re: [Patch v3 3/6] sched/fair: Implement prefer sibling imbalance calculation between asymmetric groups
From: Tim Chen
Date: Fri Jul 14 2023 - 20:11:52 EST
On Fri, 2023-07-14 at 18:44 +0530, Shrikanth Hegde wrote:
>
> > + /* Take advantage of resource in an empty sched group */
> > + if (imbalance == 0 && local->sum_nr_running == 0 &&
> > + busiest->sum_nr_running > 1)
> > + imbalance = 2;
> > +
>
> I don't see how this case would be true. When there are unequal number of cores and local->sum_nr_ruuning
> is 0, and busiest->sum_nr_running is atleast 2, imbalance will be atleast 1.
I think you are correct. With at least 2 task in the busiest group,
imbalance will be at least 1. This is the effect of doing rounding
when adding the (ncores_local + ncores_busy) rounding factor.
Returning an imbalance value of 1 will not be correct as we
will be dividing imbalance by 2 and we will still not move task
to the empty group as intended.
So this code should be updated as below:
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 3fc8d3a3bd22..16bf75e6a775 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9400,7 +9400,7 @@ static inline long sibling_imbalance(struct lb_env *env,
imbalance /= ncores_local + ncores_busiest;
/* Take advantage of resource in an empty sched group */
- if (imbalance == 0 && local->sum_nr_running == 0 &&
+ if (imbalance <= 1 && local->sum_nr_running == 0 &&
busiest->sum_nr_running > 1)
imbalance = 2;
Tim