Re: [PATCH] sched/fair: Optimize select_idle_core

From: Vincent Guittot
Date: Thu Dec 05 2019 - 13:52:57 EST


On Thu, 5 Dec 2019 at 18:52, Srikar Dronamraju
<srikar@xxxxxxxxxxxxxxxxxx> wrote:
>
> * Vincent Guittot <vincent.guittot@xxxxxxxxxx> [2019-12-05 18:27:51]:
>
> > Hi Srikar,
> >
> > On Thu, 5 Dec 2019 at 18:23, Srikar Dronamraju
> > <srikar@xxxxxxxxxxxxxxxxxx> wrote:
> > >
> > > Currently we loop through all threads of a core to evaluate if the core
> > > is idle or not. This is unnecessary. If a thread of a core is not
> > > idle, skip evaluating other threads of a core.
> >
> > I think that the goal is also to clear all CPUs of the core from the
> > cpumask of the loop above so it will not try the same core next time
> >
> > >
>
> That goal we still continue to maintain by the way of cpumask_andnot.
> i.e instead of clearing CPUs one at a time, we clear all the CPUs in the
> core at one shot.

ah yes sorry, I have been to quick and overlooked the cpumask_andnot line

>
> > > Signed-off-by: Srikar Dronamraju <srikar@xxxxxxxxxxxxxxxxxx>
> > > ---
> > > kernel/sched/fair.c | 6 ++++--
> > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > > index 69a81a5709ff..b9d628128cfc 100644
> > > --- a/kernel/sched/fair.c
> > > +++ b/kernel/sched/fair.c
> > > @@ -5872,10 +5872,12 @@ static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int
> > > bool idle = true;
> > >
> > > for_each_cpu(cpu, cpu_smt_mask(core)) {
> > > - __cpumask_clear_cpu(cpu, cpus);
> > > - if (!available_idle_cpu(cpu))
> > > + if (!available_idle_cpu(cpu)) {
> > > idle = false;
> > > + break;
> > > + }
> > > }
> > > + cpumask_andnot(cpus, cpus, cpu_smt_mask(core));
> > >
> > > if (idle)
> > > return core;
> > > --
> > > 2.18.1
> > >
>
> --
> Thanks and Regards
> Srikar Dronamraju
>