Re: [PATCH] sched/fair: Add SMT4 group_smt_balance handling

From: Tim Chen
Date: Wed Sep 06 2023 - 11:42:54 EST


On Wed, 2023-09-06 at 14:59 +0530, Shrikanth Hegde wrote:
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 6e7ee2efc1ba..48e9ab7f8a87 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -9764,16 +9764,9 @@ static bool update_sd_pick_busiest(struct lb_env *env,
> >
> > case group_smt_balance:
> > /* no idle cpus on both groups handled by group_fully_busy below */
>
> Please add a comment here explaining the fall-through and spare logic.
>

Sure.


> > - if (sgs->idle_cpus != 0 || busiest->idle_cpus != 0) {
> > - if (sgs->idle_cpus > busiest->idle_cpus)
> > - return false;
> > - if (sgs->idle_cpus < busiest->idle_cpus)
> > - return true;
> > - if (sgs->sum_nr_running <= busiest->sum_nr_running)
> > - return false;
> > - else
> > - return true;
> > - }
> > + if (sgs->idle_cpus != 0 || busiest->idle_cpus != 0)
> > + goto has_spare;
> > +
> > goto fully_busy;
>
> This can fall through without the additional goto statement no?
>

There is an unconditional goto fully_busy so won't fall through and
compiler won't complain.

> >
> > case group_fully_busy:
> > @@ -9809,6 +9802,7 @@ static bool update_sd_pick_busiest(struct lb_env *env,
> > * as we do not want to pull task off SMT core with one task
> > * and make the core idle.
> > */
> > +has_spare:
> > if (smt_vs_nonsmt_groups(sds->busiest, sg)) {
> > if (sg->flags & SD_SHARE_CPUCAPACITY && sgs->sum_h_nr_running <= 1)
> > return false;
> >
> >
> >
Tim