Re: [PATCH 5/5] sched/fair: narrow the sched_use_asym_prio checking scenario

From: Ricardo Neri
Date: Thu Jan 25 2024 - 19:05:08 EST


On Tue, Jan 23, 2024 at 02:17:00PM +0530, Shrikanth Hegde wrote:
>
>
> On 1/17/24 2:27 PM, alexs@xxxxxxxxxx wrote:
> > From: Alex Shi <alexs@xxxxxxxxxx>
> >
> > Current function doesn't match it's comments, in fact, core_idle
> > checking is only meaningful with non-SMT.

For SMT cores, we _do_ need to check for a whole core to be idle when
deciding to use asym_packing priorities when balancing between cores, but
not in SMT domains. This is what the function's documentation states.

> > So make the function right.
> >
> > Signed-off-by: Alex Shi <alexs@xxxxxxxxxx>
> > To: Valentin Schneider <vschneid@xxxxxxxxxx>
> > To: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> > To: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > To: Ingo Molnar <mingo@xxxxxxxxxx>
> > ---
> > kernel/sched/fair.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 96163ab69ae0..0a321f639c79 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -9741,8 +9741,8 @@ group_type group_classify(unsigned int imbalance_pct,
> > */
> > static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)
> > {
> > - return (!sched_smt_active()) ||
> > - (sd->flags & SD_SHARE_CPUCAPACITY) || is_core_idle(cpu);
> > + return (sd->flags & SD_SHARE_CPUCAPACITY) ||
> > + (!sched_smt_active() && is_core_idle(cpu));
> > }
>
> This seems wrong. This would always return false for higher than SMT domains
> if smt is active.

Agreed.

>
> Was this meant to be sched_smt_active() && is_core_idle(cpu)?

But this would not work if SMT is inactive, in such case checking
for a whole idle core is pointless.