Re: [PATCH] sched/fair: clean up asym packing

From: Vincent Guittot
Date: Mon Jun 03 2019 - 14:36:18 EST


On Mon, 3 Jun 2019 at 20:15, Valentin Schneider
<valentin.schneider@xxxxxxx> wrote:
>
> Hi,
>
> On 03/06/2019 15:17, Vincent Guittot wrote:
> > Clean up asym packing to follow the default load balance behavior:
> > - classify the group by creating a group_asym_capacity field.
>
> Being nitpicky here, this doesn't classify the group in the usual way
> - it doesn't get a specific group_type value (group_classify()). So maybe
> "classify" isn't the best term here.

My original goal was to add a group type to classify the group but
this would have broken the current behavior whereas I only want to
move code

>
> Also, why tag this group in update_sd_pick_busiest()? It would make more
> sense to do so in update_sg_lb_stats() like with the other sg_lb_stats fields:

With your proposal below, the test is called for every groups'
statistic update whereas it is only done lastly after checking other
rules in the current code and I don't want to modify the current
behavior but only move code to set imbalance in calculate imbalance.

A bigger cleanup will come in next steps

>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 93c24473c8a0..537710026c3a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8298,6 +8298,10 @@ static inline void update_sg_lb_stats(struct lb_env *env,
> }
> }
>
> + if (sgs->sum_nr_running &&
> + sched_asym_prefer(env->dst_cpu, group->asym_prefer_cpu))
> + sgs->group_asym_capacity = 1;
> +
> /* Adjust by relative CPU capacity of the group */
> sgs->group_capacity = group->sgc->capacity;
> sgs->avg_load = (sgs->group_load*SCHED_CAPACITY_SCALE) / sgs->group_capacity;
> @@ -8391,9 +8395,7 @@ static bool update_sd_pick_busiest(struct lb_env *env,
> * perform better since they share less core resources. Hence when we
> * have idle threads, we want them to be the higher ones.
> */
> - if (sgs->sum_nr_running &&
> - sched_asym_prefer(env->dst_cpu, sg->asym_prefer_cpu)) {
> - sgs->group_asym_capacity = 1;
> + if (sgs->group_asym_capacity) {
> if (!sds->busiest)
> return true;
>