linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Guittot <vincent.guittot@linaro.org>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	stable@vger.kernel.org, Paul Turner <pjt@google.com>
Subject: Re: [PATCH v2] sched: fix group_entity's share update
Date: Wed, 4 Jan 2017 18:48:19 +0100	[thread overview]
Message-ID: <CAKfTPtA3n4OtzwG9rA2d2-2Nw4hbnk-FLv__e4XeXqRiJEycog@mail.gmail.com> (raw)
In-Reply-To: <b2b40a24-e3c0-ba81-df12-3466a28eb5e7@arm.com>

On 4 January 2017 at 18:20, Dietmar Eggemann <dietmar.eggemann@arm.com> wrote:
> On 21/12/16 15:50, Vincent Guittot wrote:
>
> IMHO, the overall idea makes sense to me. Just a couple of small
> questions ...
>
>> The update of the share of a cfs_rq is done when its load_avg is updated
>> but before the group_entity's load_avg has been updated for the past time
>> slot. This generates wrong load_avg accounting which can be significant
>> when small tasks are involved in the scheduling.
>
> Why for small tasks? Is it because we use load =
> scale_load_down(cfs_rq->load.weight) and not load = cfs_rq->avg.load_avg
> in calc_cfs_shares()?

small tasks are significantly impacted because the tick has less
chance to fire while task is running and as a result less chance to
update group entity's load_avg of the past tick with the correct
weight and minimize the impact of this bug.

>
>> Let take the example of a task a that is dequeued of its task group A:
>>    root
>>   (cfs_rq)
>>     \
>>     (se)
>>      A
>>     (cfs_rq)
>>       \
>>       (se)
>>        a
>>
>> Task "a" was the only task in task group A which becomes idle when a is
>> dequeued.
>>
>> We have the sequence:
>>
>> - dequeue_entity a->se
>>     - update_load_avg(a->se)
>>     - dequeue_entity_load_avg(A->cfs_rq, a->se)
>>     - update_cfs_shares(A->cfs_rq)
>>       A->cfs_rq->load.weight == 0
>
> You mean A->cfs_rq->load.weight = 0 ?

no A->cfs_rq->load.weight == 0. Just to point out that
A->cfs_rq->load.weight equals 0 at that time.
A->cfs_rq->load.weight has been set to 0 in account_entity_dequeue()
which is not described here and happen between
dequeue_entity_load_avg() and update_cfs_shares()

>
>>         A->se->load.weight is updated with the new share (0 in this case)
>
> Shouldn't this be MIN_SHARES (2) instead of 0?

yes you're right
I had in mind scale_load_down(se->load.weight) which is used when
calling  __update_load_avg() in update_load_avg() and which is 0 on
the 64bits platform that I used

>
>> - dequeue_entity A->se
>>     - update_load_avg(A->se) but its weight is now null so the last time
>>       slot (up to a tick) will be accounted with a weight of 0 instead of
>>       its real weight during the time slot. The last time slot will be
>>       accounted as an idle one whereas it was a running one.
>>
>> If the running time of task a is short enough that no tick happens when it
>> runs, all running time of group entity A->se will be accounted as idle
>> time.
>>
>> Instead, we should update the share of a cfs_rq (in fact the weight of its
>> group entity) only after having updated the load_avg of the group_entity.
>
> This is because we use 'se->on_rq * scale_load_down(se->load.weight)' in
> __update_load_avg() as weight parameter for PELT load_avg update?

yes

>
>> update_cfs_shares() now take the sched_entity as parameter instead of the
>> cfs_rq and  the weight of the group_entity is updated only once its load_avg
>> has been synced with current time.
>
> [...]
>

  reply	other threads:[~2017-01-04 17:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-21 15:50 [PATCH v2] sched: fix group_entity's share update Vincent Guittot
2017-01-04 17:20 ` Dietmar Eggemann
2017-01-04 17:48   ` Vincent Guittot [this message]
2017-01-14 12:48 ` [tip:sched/core] sched/core: Fix " tip-bot for Vincent Guittot

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=CAKfTPtA3n4OtzwG9rA2d2-2Nw4hbnk-FLv__e4XeXqRiJEycog@mail.gmail.com \
    --to=vincent.guittot@linaro.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).