Re: [PATCH] sched/fair: Move calculate of avg_load to a better location

From: Vincent Guittot
Date: Wed Apr 06 2022 - 13:21:47 EST


On Wed, 6 Apr 2022 at 11:57, zgpeng <zgpeng.linux@xxxxxxxxx> wrote:
>
> In calculate_imbalance function, when the value of local->avg_load is
> greater than or equal to busiest->avg_load, the calculated sds->avg_load is
> not used. So this calculation can be placed in a more appropriate position.
>
> Signed-off-by: zgpeng <zgpeng@xxxxxxxxxxx>
> Reviewed-by: Samuel Liao <samuelliao@xxxxxxxxxxx>

Reviewed-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>

> ---
> kernel/sched/fair.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index d4bd299..601f8bd 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9460,8 +9460,6 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
> local->avg_load = (local->group_load * SCHED_CAPACITY_SCALE) /
> local->group_capacity;
>
> - sds->avg_load = (sds->total_load * SCHED_CAPACITY_SCALE) /
> - sds->total_capacity;
> /*
> * If the local group is more loaded than the selected
> * busiest group don't try to pull any tasks.
> @@ -9470,6 +9468,9 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
> env->imbalance = 0;
> return;
> }
> +
> + sds->avg_load = (sds->total_load * SCHED_CAPACITY_SCALE) /
> + sds->total_capacity;
> }
>
> /*
> --
> 2.9.5
>