mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Byungchul Park <byungchul.park@lge.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: perterz@infradead.org, Frederic Weisbecker <fweisbec@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Chris Metcalf <cmetcalf@ezchip.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Christoph Lameter <cl@linux.com>,
	"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>,
	Mike Galbraith <efault@gmx.de>, Rik van Riel <riel@redhat.com>
Subject: Re: [RFC PATCH 0/4] sched: Improve cpu load accounting with nohz
Date: Wed, 20 Jan 2016 13:04:52 +0000	[thread overview]
Message-ID: <569F85F4.9070500@arm.com> (raw)
In-Reply-To: <20160120004825.GB9882@X58A-UD3R>

On 20/01/16 00:48, Byungchul Park wrote:
> On Tue, Jan 19, 2016 at 02:04:57PM +0100, Peter Zijlstra wrote:
>> On Fri, Jan 15, 2016 at 04:56:36PM +0000, Dietmar Eggemann wrote:
>>> Couldn't we set tickless_load only in case:
>>>
>>> unsigned long tickless_load = (active && pending_updates > 1) ?
>>> this_rq->cpu_load[0] : 0;
>>>
>>> Even though update_cpu_load_nohz() can call with pending_updates=1 and
>>> active=1 but then we don't have to decay.
>>
>> decay_load_missed() has an early bail for !missed, which will be tickled
>> with pending_updates == 1.
> 
> I think the way for decay_load_missed() to get an early bail for
> *!load*, which the Dietmar's proposal did, is also good. And the
> peterz's proposal avoiding an unnecessary "add" operation is also
> good. Whatever..
> 
>>
>> What I was thinking of doing however is:
>>
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -4445,13 +4445,15 @@ static void __update_cpu_load(struct rq
>>  
>>  		old_load = this_rq->cpu_load[i];
>>  		old_load = decay_load_missed(old_load, pending_updates - 1, i);
>> -		old_load -= decay_load_missed(tickless_load, pending_updates - 1, i);
>> -		/*
>> -		 * old_load can never be a negative value because a decayed
>> -		 * tickless_load cannot be greater than the original
>> -		 * tickless_load.
>> -		 */
>> -		old_load += tickless_load;
>> +		if (tickless_load) {
> 
> And additionally, in this approach, why don't you do like,
> 
>                 if (tickless_load || pending_updates - 1)
> 
>> +			old_load -= decay_load_missed(tickless_load, pending_updates - 1, i);
>> +			/*
>> +			 * old_load can never be a negative value because a
>> +			 * decayed tickless_load cannot be greater than the
>> +			 * original tickless_load.
>> +			 */
>> +			old_load += tickless_load;
>> +		}
>>  		new_load = this_load;
>>  		/*
>>  		 * Round up the averaging division if load is increasing. This
>>
>>
>> Since regardless of the pending_updates, none of that makes sense if
>> !tickless_load.
> 
> None of that makes sense if !(pending_updates - 1), too. In that case,
> it becomes,
> 
>                         old_load -= tickless_load;
>                         old_load += tickless_load;
> 

tickless_load is potentially set to != 0 (rq->cpu_load[0]) in case
__update_cpu_load() is called by:

 tick_nohz_full_update_tick()->tick_nohz_restart_sched_tick()->
 update_cpu_load_nohz() [CONFIG_NO_HZ_FULL=y]

 scheduler_tick()->update_cpu_load_active()

The former can call with pending_updates=1 and the latter always calls
w/ pending_updates=1 which makes it impossible to set tickless_load
correctly in __update_cpu_load(). I guess an enum indicating the caller
(update_cpu_load_active() update_cpu_load_nohz() or
update_idle_cpu_load) would help if we want to do this super correctly.

I don't have a strong preference whether we do 'if (tickless_load)' or
let decay_load_missed() bail when load = 0 (latter is not really
necessary because decay_load_missed() can handle load=0 already.
But if we do 'if (tickless_load)' why don't we also do 'if(old_load)'?
(old_load can be 0 as well)

Anyway, the patch fixes the unsigned underflow issue I saw for the
cpu_load[] values in NO_HZ_FULL mode.

Maybe you could fix the __update_cpu_load header as well:

'@active: !0 for NOHZ_FULL' (not really true, also when called by
update_cpu_load_active())
s/decay_load_misses()/decay_load_missed()
s/@active paramter/@active parameter

Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>

  reply	other threads:[~2016-01-20 13:04 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-13 16:01 Frederic Weisbecker
2016-01-13 16:01 ` [PATCH 1/4] sched: Don't account tickless CPU load on tick Frederic Weisbecker
2016-01-19 13:08   ` Peter Zijlstra
2016-01-19 16:22     ` Frederic Weisbecker
2016-01-19 18:56       ` Peter Zijlstra
2016-01-19 22:33         ` Frederic Weisbecker
2016-01-20  5:43           ` Byungchul Park
2016-01-20 10:26             ` Byungchul Park
2016-01-28 16:01               ` Frederic Weisbecker
2016-01-29  9:50                 ` Peter Zijlstra
2016-02-01 10:05                   ` Byungchul Park
2016-02-01 10:09                     ` [PATCH] sched: calculate sched_clock_cpu without tick handling during nohz Byungchul Park
2016-02-01 10:34                     ` [PATCH 1/4] sched: Don't account tickless CPU load on tick Peter Zijlstra
2016-02-01 23:51                       ` Byungchul Park
2016-02-02  0:50                       ` Byungchul Park
2016-02-01  6:33               ` Byungchul Park
2016-01-20  8:42     ` Thomas Gleixner
2016-01-20 17:36       ` Frederic Weisbecker
2016-01-22  8:40       ` Byungchul Park
2016-01-13 16:01 ` [PATCH 2/4] sched: Consolidate nohz CPU load update code Frederic Weisbecker
2016-01-14  2:30   ` Byungchul Park
2016-01-19 13:13     ` Peter Zijlstra
2016-01-20  0:51       ` Byungchul Park
2016-01-14  5:18   ` Byungchul Park
2016-01-19 13:13     ` Peter Zijlstra
2016-01-19 16:49     ` Frederic Weisbecker
2016-01-20  1:41       ` Byungchul Park
2016-02-29 11:14   ` [tip:sched/core] sched/fair: " tip-bot for Frederic Weisbecker
2016-01-13 16:01 ` [RFC PATCH 3/4] sched: Move cpu load stats functions above fair queue callbacks Frederic Weisbecker
2016-01-13 16:01 ` [RFC PATCH 4/4] sched: Upload nohz full CPU load on task enqueue/dequeue Frederic Weisbecker
2016-01-19 13:17   ` Peter Zijlstra
2016-01-19 17:03     ` Frederic Weisbecker
2016-01-20  9:09       ` Peter Zijlstra
2016-01-20 14:54         ` Frederic Weisbecker
2016-01-20 15:11           ` Thomas Gleixner
2016-01-20 15:19             ` Christoph Lameter
2016-01-20 16:52               ` Frederic Weisbecker
2016-01-20 16:45             ` Frederic Weisbecker
2016-01-20 16:56           ` Peter Zijlstra
2016-01-20 17:21             ` Frederic Weisbecker
2016-01-20 18:25               ` Peter Zijlstra
2016-01-21 13:25                 ` Frederic Weisbecker
2016-01-20  9:03   ` Thomas Gleixner
2016-01-20 14:31     ` Frederic Weisbecker
2016-01-20 14:43       ` Thomas Gleixner
2016-01-20 16:40         ` Frederic Weisbecker
2016-01-20 16:42           ` Christoph Lameter
2016-01-20 16:47             ` Frederic Weisbecker
2016-01-14 21:19 ` [RFC PATCH 0/4] sched: Improve cpu load accounting with nohz Dietmar Eggemann
2016-01-14 21:27   ` Peter Zijlstra
2016-01-14 22:23     ` Dietmar Eggemann
2016-01-15  7:07       ` Byungchul Park
2016-01-15 16:56         ` Dietmar Eggemann
2016-01-18  0:23           ` Byungchul Park
2016-01-19 13:04           ` Peter Zijlstra
2016-01-20  0:48             ` Byungchul Park
2016-01-20 13:04               ` Dietmar Eggemann [this message]
2016-02-29 11:14         ` [tip:sched/core] sched/fair: Avoid using decay_load_missed() with a negative value tip-bot for Byungchul Park

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=569F85F4.9070500@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=byungchul.park@lge.com \
    --cc=cl@linux.com \
    --cc=cmetcalf@ezchip.com \
    --cc=efault@gmx.de \
    --cc=fweisbec@gmail.com \
    --cc=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=perterz@infradead.org \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome