public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yuyang Du <yuyang.du@intel.com>
To: bsegall@google.com
Cc: mingo@redhat.com, peterz@infradead.org,
	linux-kernel@vger.kernel.org, pjt@google.com,
	arjan.van.de.ven@intel.com, len.brown@intel.com,
	rafael.j.wysocki@intel.com, alan.cox@intel.com,
	mark.gross@intel.com, fengguang.wu@intel.com
Subject: Re: [PATCH 2/2 v2] sched: Rewrite per entity runnable load average tracking
Date: Wed, 16 Jul 2014 07:45:05 +0800	[thread overview]
Message-ID: <20140715234505.GA2901@intel.com> (raw)
In-Reply-To: <xm26pph6wmzy.fsf@sword-of-the-dawn.mtv.corp.google.com>

On Tue, Jul 15, 2014 at 10:27:45AM -0700, bsegall@google.com wrote:
> >  
> >> > +static __always_inline u64 decay_load64(u64 val, u64 n)
> >> > +{
> >> > +	if (likely(val <= UINT_MAX))
> >> > +		val = decay_load(val, n);
> >> > +	else {
> >> > +		/*
> >> > +		 * LOAD_AVG_MAX can last ~500ms (=log_2(LOAD_AVG_MAX)*32ms).
> >> > +		 * Since we have so big runnable load_avg, it is impossible
> >> > +		 * load_avg has not been updated for such a long time. So
> >> > +		 * LOAD_AVG_MAX is enough here.
> >> > +		 */
> >> 
> >> I mean, LOAD_AVG_MAX is irrelevant - the constant could just as well be
> >> 1<<20, or whatever, yes? In fact, if you're going to then turn it into a
> >> fraction of 1<<10, just do (with whatever temporaries you find most tasteful):
> >> 
> >> val *= (u32) decay_load(1 << 10, n);
> >> val >>= 10;
> >> 
> >
> > LOAD_AVG_MAX is selected on purpose. The val arriving here specifies that it is really
> > big. So the decay_load may not decay it to 0 even period n is not small. If we use 1<<10
> > here, n=10*32 will decay it to 0, but val (larger than 1<<32) can
> > survive.
> 
> But when you do *1024 / LOAD_AVG_MAX it will go back to zero. In general
> the code you have now is exactly equivalent to factor = decay_load(1<<10,n)
> ignoring possible differences in rounding.
> 
Oh, yes...., I did not go to that deep.

Then to avoid this, maybe should first val*factor, then val/LOAD_AVG_MAX, but then risk
overflow again... Ok, I will do:

val *= (u32) decay_load(1 << 10, n);
val >>= 10;

if not enough, I believe decay_load(1 << 15, n) should be safe too.

Thanks a lot,
Yuyang

  reply	other threads:[~2014-07-16  7:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13 23:15 [PATCH 0/2 v2] sched: Rewrite per entity runnable load average tracking Yuyang Du
2014-07-13 23:15 ` [PATCH 1/2 v2] sched: Remove update_rq_runnable_avg Yuyang Du
2014-07-13 23:15 ` [PATCH 2/2 v2] sched: Rewrite per entity runnable load average tracking Yuyang Du
2014-07-14 19:33   ` bsegall
2014-07-15  1:51     ` Yuyang Du
2014-07-15 17:27       ` bsegall
2014-07-15 23:45         ` Yuyang Du [this message]
2014-07-16  8:27         ` Mike Galbraith

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=20140715234505.GA2901@intel.com \
    --to=yuyang.du@intel.com \
    --cc=alan.cox@intel.com \
    --cc=arjan.van.de.ven@intel.com \
    --cc=bsegall@google.com \
    --cc=fengguang.wu@intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.gross@intel.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=rafael.j.wysocki@intel.com \
    /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