[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGsJ_4xP7=LZnX1hSMi=2T_9xUmNCtbpyiFi+Uxs0_cxYX3E-A@mail.gmail.com>
Date: Thu, 25 Nov 2021 09:49:19 +1300
From: Barry Song <21cnbao@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>, Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Steven Rostedt <rostedt@...dmis.org>,
LKML <linux-kernel@...r.kernel.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Barry Song <song.bao.hua@...ilicon.com>
Subject: Re: [PATCH v2] sched/fair: Remove the cost of a redundant
cpumask_next_wrap in select_idle_cpu
On Thu, Nov 25, 2021 at 4:02 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Thu, Nov 25, 2021 at 01:02:00AM +1300, Barry Song wrote:
> > On Thu, Nov 25, 2021 at 12:57 AM Barry Song <21cnbao@...il.com> wrote:
>
> > > Let me make it clearer. if nr=5, the original code will loop 5 times,
> > > but in the 5th loop, it returns directly, so __select_idle_cpu is
> > > only done 4 times.
> > >
> > > if nr=1, the original code will loop 1 time, but in the 1st loop,
> > > it returns directly, so __select_idle_cpu is done 0 times.
> >
> > this is also why in the first version of patch, i did this:
> > span_avg = sd->span_weight * avg_idle;
> > if (span_avg > 4*avg_cost)
> > - nr = div_u64(span_avg, avg_cost);
> > + nr = div_u64(span_avg, avg_cost) - 1;
> > else
> > - nr = 4;
> > + nr = 3;
> >
> > because we are actually scanning 3 times or div_u64(span_avg, avg_cost) - 1
> > times but not 4 times or div_u64(span_avg, avg_cost) times.
>
> It still is confusing, because > 4*span -> nr = avg/span, very much
> implies we want to bottom out at 4.
>
> > this is not confusing at all. the only thing which is confusing is the original
> > code.
>
> But yes, it seems a whole lot of confusion stacked together. Let make it
> sane and say that we do 'nr' iterations, because clearly that was the
> intent :-)
yes. It seems this is much more sensible to do iterations in the
number of nr rather than
nr-1. we can achieve this goal by two ways:
(1)
nr--;
for_each_cpu_wrap(cpu, cpus, target + 1) {
_select_idle_cpu()....
if (!nr--)
return;
}
(2)
for_each_cpu_wrap(cpu, cpus, target + 1) {
_select_idle_cpu()....
if (!--nr)
return;
}
it seems the second way is still better as we don't need the "nr--" before
for_each_cpu_wrap() ?
Thanks
Barry
Powered by blists - more mailing lists