[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6cd1633036bb6b651af575c32c2a9608a106702c.camel@linux.intel.com>
Date: Thu, 07 Sep 2023 10:42:21 -0700
From: Tim Chen <tim.c.chen@...ux.intel.com>
To: Shrikanth Hegde <sshegde@...ux.vnet.ibm.com>,
Peter Zijlstra <peterz@...radead.org>
Cc: bristot@...hat.com, bsegall@...gle.com, dietmar.eggemann@....com,
hdanton@...a.com, ionela.voinescu@....com, juri.lelli@...hat.com,
len.brown@...el.com, linux-kernel@...r.kernel.org, mgorman@...e.de,
naveen.n.rao@...ux.vnet.ibm.com, rafael.j.wysocki@...el.com,
ravi.v.shankar@...el.com, ricardo.neri@...el.com,
rostedt@...dmis.org, srikar@...ux.vnet.ibm.com,
srinivas.pandruvada@...ux.intel.com, v-songbaohua@...o.com,
vincent.guittot@...aro.org, vschneid@...hat.com, x86@...nel.org,
yangyicong@...ilicon.com, yu.c.chen@...el.com
Subject: Re: [PATCH] sched/fair: Add SMT4 group_smt_balance handling
On Thu, 2023-09-07 at 14:28 +0530, Shrikanth Hegde wrote:
> >
> > You mean simplify the patch as below? I think that should be fine. Can you
> > make sure it works for SMT4? And I can update the patch once you confirm it
> > works properly.
> >
> > Tim
> >
> > 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 */
> > - 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;
> >
> > 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;
> >
> >
> >
>
> Hi Tim,
>
> In case you were waiting for my reply as inferred from other email.
> The above change looks fine as well. This would avoid duplication of
> code for group_smt_balance.
>
> Acked-by: Shrikanth Hegde <sshegde@...ux.vnet.ibm.com>
Peter,
Here's the updated patch. Please consider it for inclusion.
Thanks.
Tim
>From 979e261fed6e3765316a4de794f595f93c02cef0 Mon Sep 17 00:00:00 2001
From: Tim Chen <tim.c.chen@...ux.intel.com>
Subject: [PATCH] sched/fair: Fix SMT4 group_smt_balance handling
To: Peter Zijlstra <peterz@...radead.org>
Cc: Juri Lelli <juri.lelli@...hat.com>, Vincent Guittot <vincent.guittot@...aro.org>, Ricardo Neri <ricardo.neri@...el.com>, Ravi V. Shankar <ravi.v.shankar@...el.com>, Ben Segall
<bsegall@...gle.com>, Daniel Bristot de Oliveira <bristot@...hat.com>, Dietmar Eggemann <dietmar.eggemann@....com>, Len Brown <len.brown@...el.com>, Mel Gorman <mgorman@...e.de>, Rafael J. Wysocki
<rafael.j.wysocki@...el.com>, Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>, Steven Rostedt <rostedt@...dmis.org>, Tim Chen <tim.c.chen@...ux.intel.com>, Valentin Schneider
<vschneid@...hat.com>, Ionela Voinescu <ionela.voinescu@....com>, x86@...nel.org, linux-kernel@...r.kernel.org, Shrikanth Hegde <sshegde@...ux.vnet.ibm.com>, Srikar Dronamraju
<srikar@...ux.vnet.ibm.com>, naveen.n.rao@...ux.vnet.ibm.com, Yicong Yang <yangyicong@...ilicon.com>, Barry Song <v-songbaohua@...o.com>, Chen Yu <yu.c.chen@...el.com>, Hillf Danton <hdanton@...a.com>
For SMT4, any group with more than 2 tasks will be marked as
group_smt_balance. Retain the behaviour of group_has_spare by marking
the busiest group as the group which has the least number of idle_cpus.
Also, handle rounding effect of adding (ncores_local + ncores_busy) when
the local is fully idle and busy group imbalance is less than 2 tasks.
Local group should try to pull at least 1 task in this case so imbalance
should be set to 2 instead.
Fixes: fee1759e4f04 ("sched/fair: Determine active load balance for SMT sched groups")
Acked-by: Shrikanth Hegde <sshegde@...ux.vnet.ibm.com>
Signed-off-by: Tim Chen <tim.c.chen@...ux.intel.com>
---
kernel/sched/fair.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0b7445cd5af9..fd9e594b5623 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9575,7 +9575,7 @@ static inline long sibling_imbalance(struct lb_env *env,
imbalance /= ncores_local + ncores_busiest;
/* Take advantage of resource in an empty sched group */
- if (imbalance == 0 && local->sum_nr_running == 0 &&
+ if (imbalance <= 1 && local->sum_nr_running == 0 &&
busiest->sum_nr_running > 1)
imbalance = 2;
@@ -9763,6 +9763,15 @@ static bool update_sd_pick_busiest(struct lb_env *env,
break;
case group_smt_balance:
+ /*
+ * Check if we have spare CPUs on either SMT group to
+ * choose has spare or fully busy handling.
+ */
+ if (sgs->idle_cpus != 0 || busiest->idle_cpus != 0)
+ goto has_spare;
+
+ fallthrough;
+
case group_fully_busy:
/*
* Select the fully busy group with highest avg_load. In
@@ -9802,6 +9811,7 @@ static bool update_sd_pick_busiest(struct lb_env *env,
else
return true;
}
+has_spare:
/*
* Select not overloaded group with lowest number of idle cpus
--
2.32.0
Powered by blists - more mailing lists