Re: [PATCH v2 1/4] sched/fair: Optimize checking for group_asym_packing
From: Ricardo Neri
Date: Mon May 03 2021 - 23:09:06 EST
On Mon, May 03, 2021 at 11:24:25AM +0200, Peter Zijlstra wrote:
> On Tue, Apr 13, 2021 at 07:04:33PM -0700, Ricardo Neri wrote:
> > By checking local_group, we can avoid additional checks and invoking
> > sched_asmy_prefer() when it is not needed.
>
> This really could do with a few words on *why* that is correct. ISTR
> thinking this made sense when I last looked at it, but today, after
> having the brain reset by not looking at a computer for 4 days its not
> immediate obvious anymore.
Thanks for your feedback Peter! I will add a comment explaining why this
is correct: when we are collecting statistics of the local group,
@env->dst_cpu belongs to @group. @env->dst_cpu may or may not be
@group->asym_prefer_cpu. If @env->dst_cpu, sched_asym_prefer() must return
false because it would be checking for
arch_asym_cpu_priority(dst_cpu) > arch_asym_cpu_priority(dst_cpu)
which is false. If @env->dst_cpu is not @group->env_prefer_cpu, it
implies that the former has lower prority than the latter and
sched_asym_prefer() will also return false.
Thanks and BR,
Ricardo
>
> > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@xxxxxxxxxxxxxxx>
> > ---
> > 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 04a3ce20da67..4ef3fa0d5e8d 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -8455,7 +8455,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
> > }
> >
> > /* Check if dst CPU is idle and preferred to this group */
> > - if (env->sd->flags & SD_ASYM_PACKING &&
> > + if (!local_group && env->sd->flags & SD_ASYM_PACKING &&
> > env->idle != CPU_NOT_IDLE &&
> > sgs->sum_h_nr_running &&
> > sched_asym_prefer(env->dst_cpu, group->asym_prefer_cpu)) {
> > --
> > 2.17.1
> >