From: Michael wang <wangyun@linux.vnet.ibm.com>
To: Alex Shi <alex.shi@linaro.org>,
mingo@redhat.com, peterz@infradead.org, morten.rasmussen@arm.com,
vincent.guittot@linaro.org, daniel.lezcano@linaro.org,
efault@gmx.de
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 1/2] sched/update_avg: avoid negative time
Date: Tue, 21 Jan 2014 14:49:39 +0800 [thread overview]
Message-ID: <52DE1883.2070304@linux.vnet.ibm.com> (raw)
In-Reply-To: <1390282399-17091-1-git-send-email-alex.shi@linaro.org>
Hi, Alex
On 01/21/2014 01:33 PM, Alex Shi wrote:
> rq->avg_idle try to reflect the average idle time between the cpu idle
> and first wakeup. But in the function, it maybe get a negative value
> if old avg_idle is too small. Then this negative value will be double
> counted in next time calculation. Guess that is not the original purpose,
> so recalibrate it to zero.
>
> Signed-off-by: Alex Shi <alex.shi@linaro.org>
> ---
> kernel/sched/core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 30eb011..af9121c6 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1358,6 +1358,9 @@ static void update_avg(u64 *avg, u64 sample)
> {
> s64 diff = sample - *avg;
> *avg += diff >> 3;
> +
> + if (*avg < 0)
> + *avg = 0;
This seems like won't happen...
if 'diff' is negative, it's absolute value won't bigger than '*avg', not
to mention we only use 1/8 of it.
Regards,
Michael Wang
> }
> #endif
>
next prev parent reply other threads:[~2014-01-21 6:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-21 5:33 [RFC PATCH 1/2] sched/update_avg: avoid negative time Alex Shi
2014-01-21 5:33 ` [PATCH 2/2] sched: add statistic for rq->max_idle_balance_cost Alex Shi
2014-01-21 7:43 ` Jason Low
2014-01-21 8:44 ` Alex Shi
2014-01-22 8:24 ` Alex Shi
2014-01-22 16:09 ` Peter Zijlstra
2014-01-22 18:10 ` Jason Low
2014-01-23 6:49 ` Alex Shi
2014-01-23 9:54 ` Peter Zijlstra
2014-01-23 10:49 ` Alex Shi
2014-01-23 12:32 ` Morten Rasmussen
2014-01-23 14:43 ` Alex Shi
2014-02-11 12:17 ` [tip:sched/core] sched: Add statistic for newidle load balance cost tip-bot for Alex Shi
2014-01-21 5:59 ` [RFC PATCH 1/2] sched/update_avg: avoid negative time Alex Shi
2014-01-21 6:49 ` Michael wang [this message]
2014-01-21 8:46 ` Alex Shi
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=52DE1883.2070304@linux.vnet.ibm.com \
--to=wangyun@linux.vnet.ibm.com \
--cc=alex.shi@linaro.org \
--cc=daniel.lezcano@linaro.org \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=peterz@infradead.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.