Re: [Patch v2 1/6] sched/fair: Determine active load balance for SMT sched groups

From: Tim Chen
Date: Mon Jun 12 2023 - 16:13:13 EST


On Mon, 2023-06-12 at 13:13 +0200, Peter Zijlstra wrote:
>
>
>
> > @@ -9537,6 +9581,18 @@ static bool update_sd_pick_busiest(struct lb_env *env,
> > break;
> >
> > case group_has_spare:
> > + /*
> > + * Do not pick sg with SMT CPUs over sg with pure CPUs,
> > + * as we do not want to pull task off half empty SMT core
> > + * and make the core idle.
> > + */
> > + if (smt_vs_nonsmt_groups(sds->busiest, sg)) {
> > + if (sg->flags & SD_SHARE_CPUCAPACITY)
> > + return false;
> > + else
> > + return true;
> > + }
>
> However, here I'm not at all sure. Consider SMT-4 with 2 active CPUs, we
> still very much would like to pull one task off if we have an idle core
> somewhere, no?
>

How about making this modification to take care of SMT-4 case?

Tim

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 33246dce10db..e2261c24e536 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9642,11 +9642,11 @@ static bool update_sd_pick_busiest(struct lb_env *env,
case group_has_spare:
/*
* Do not pick sg with SMT CPUs over sg with pure CPUs,
- * as we do not want to pull task off half empty SMT core
+ * as we do not want to pull task off SMT core with one task
* and make the core idle.
*/
if (smt_vs_nonsmt_groups(sds->busiest, sg)) {
- if (sg->flags & SD_SHARE_CPUCAPACITY)
+ if (sg->flags & SD_SHARE_CPUCAPACITY && sgs->sum_h_nr_running <= 1)
return false;
else
return true;