public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Barry Song <21cnbao@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Barry Song <song.bao.hua@hisilicon.com>
Subject: Re: [PATCH v2] sched/fair: Remove the cost of a redundant cpumask_next_wrap in select_idle_cpu
Date: Wed, 24 Nov 2021 16:02:38 +0100	[thread overview]
Message-ID: <YZ5UDuCII/KHUb9h@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAGsJ_4zpN98_J2aRHyqz4XvSzP+0ngVu2k=ufn9JQNMwe7zZjw@mail.gmail.com>

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@gmail.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 :-)

  reply	other threads:[~2021-11-24 15:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24  9:15 [PATCH v2] sched/fair: Remove the cost of a redundant cpumask_next_wrap in select_idle_cpu Barry Song
2021-11-24 11:13 ` Peter Zijlstra
2021-11-24 11:49   ` Barry Song
2021-11-24 11:57     ` Barry Song
2021-11-24 12:02       ` Barry Song
2021-11-24 15:02         ` Peter Zijlstra [this message]
2021-11-24 20:49           ` Barry Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZ5UDuCII/KHUb9h@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=21cnbao@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=song.bao.hua@hisilicon.com \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox