From: Yuyang Du <yuyang.du@intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Steve Muckle <steve.muckle@linaro.org>,
Ingo Molnar <mingo@redhat.com>,
Morten Rasmussen <morten.rasmussen@arm.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Patrick Bellasi <patrick.bellasi@arm.com>,
Juri Lelli <Juri.Lelli@arm.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: PELT initial task load and wake_up_new_task()
Date: Thu, 17 Dec 2015 10:16:37 +0800 [thread overview]
Message-ID: <20151217021637.GK28098@intel.com> (raw)
In-Reply-To: <20151217094303.GS6357@twins.programming.kicks-ass.net>
On Thu, Dec 17, 2015 at 10:43:03AM +0100, Peter Zijlstra wrote:
> On Thu, Dec 17, 2015 at 07:34:27AM +0800, Yuyang Du wrote:
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index e3266eb..3f6a8b3 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -2908,10 +2908,18 @@ void remove_entity_load_avg(struct sched_entity *se)
> > {
> > struct cfs_rq *cfs_rq = cfs_rq_of(se);
> > u64 last_update_time;
> > -
> > #ifndef CONFIG_64BIT
> > u64 last_update_time_copy;
> > +#endif
> >
> > + /*
> > + * Newly created task or never used group entity should not be removed
> > + * from its (source) cfs_rq
> > + */
> > + if (se->avg.last_update_time == 0)
> > + return;
> > +
> > +#ifndef CONFIG_64BIT
> > do {
> > last_update_time_copy = cfs_rq->load_last_update_time_copy;
> > smp_rmb();
>
> So that ifdef stuff annoyed me a wee bit, so I did the below.
>
> Initially I wanted to do a macro that we could use for both this and the
> vruntime, but that didn't end up particularly pretty either, so I
> scrapped that.
Oh yeah, looks good. :)
> ---
> Subject: sched: Fix new task's load avg removed from source CPU in wake_up_new_task()
> From: Yuyang Du <yuyang.du@intel.com>
> Date: Thu, 17 Dec 2015 07:34:27 +0800
>
> If a newly created task is selected to go to a different CPU in fork
> balance when it wakes up the first time, its load averages should
> not be removed from the source CPU since they are never added to
> it before. The same is also applicable to a never used group entity.
>
> Fix it in remove_entity_load_avg(): when entity's last_update_time
> is 0, simply return. This should precisely identify the case in
> question, because in other migrations, the last_update_time is set
> to 0 after remove_entity_load_avg().
>
> Reported-by: Steve Muckle <steve.muckle@linaro.org>
> Signed-off-by: Yuyang Du <yuyang.du@intel.com>
> Cc: Patrick Bellasi <patrick.bellasi@arm.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Vincent Guittot <vincent.guittot@linaro.org>
> Cc: Juri Lelli <Juri.Lelli@arm.com>
> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
> Cc: Morten Rasmussen <morten.rasmussen@arm.com>
> [peterz: cfs_rq_last_update_time]
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Link: http://lkml.kernel.org/r/20151216233427.GJ28098@intel.com
> ---
> kernel/sched/fair.c | 38 ++++++++++++++++++++++++++++----------
> 1 file changed, 28 insertions(+), 10 deletions(-)
>
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2809,27 +2809,45 @@ dequeue_entity_load_avg(struct cfs_rq *c
> max_t(s64, cfs_rq->runnable_load_sum - se->avg.load_sum, 0);
> }
>
> -/*
> - * Task first catches up with cfs_rq, and then subtract
> - * itself from the cfs_rq (task must be off the queue now).
> - */
> -void remove_entity_load_avg(struct sched_entity *se)
> -{
> - struct cfs_rq *cfs_rq = cfs_rq_of(se);
> - u64 last_update_time;
> -
> #ifndef CONFIG_64BIT
> +static inline u64 cfs_rq_last_update_time(struct cfs_rq *cfs_rq)
> +{
> u64 last_update_time_copy;
> + u64 last_update_time;
>
> do {
> last_update_time_copy = cfs_rq->load_last_update_time_copy;
> smp_rmb();
> last_update_time = cfs_rq->avg.last_update_time;
> } while (last_update_time != last_update_time_copy);
> +
> + return last_update_time;
> +}
> #else
> - last_update_time = cfs_rq->avg.last_update_time;
> +static inline u64 cfs_rq_last_update_time(struct cfs_rq *cfs_rq)
> +{
> + return cfs_rq->avg.last_update_time;
> +}
> #endif
>
> +/*
> + * Task first catches up with cfs_rq, and then subtract
> + * itself from the cfs_rq (task must be off the queue now).
> + */
> +void remove_entity_load_avg(struct sched_entity *se)
> +{
> + struct cfs_rq *cfs_rq = cfs_rq_of(se);
> + u64 last_update_time;
> +
> + /*
> + * Newly created task or never used group entity should not be removed
> + * from its (source) cfs_rq
> + */
> + if (se->avg.last_update_time == 0)
> + return;
> +
> + last_update_time = cfs_rq_last_update_time(cfs_rq);
> +
> __update_load_avg(last_update_time, cpu_of(rq_of(cfs_rq)), &se->avg, 0, 0, NULL);
> atomic_long_add(se->avg.load_avg, &cfs_rq->removed_load_avg);
> atomic_long_add(se->avg.util_avg, &cfs_rq->removed_util_avg);
next prev parent reply other threads:[~2015-12-17 10:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-12 2:01 PELT initial task load and wake_up_new_task() Steve Muckle
2015-12-13 19:13 ` Yuyang Du
2015-12-15 0:41 ` Steve Muckle
2015-12-15 2:24 ` Yuyang Du
2015-12-15 18:45 ` Steve Muckle
2015-12-15 23:55 ` Yuyang Du
2015-12-16 7:58 ` [PATCH] sched: Fix new task's load avg removed from source CPU in kbuild test robot
2015-12-17 2:50 ` PELT initial task load and wake_up_new_task() Steve Muckle
2015-12-16 23:34 ` Yuyang Du
2015-12-17 9:43 ` Peter Zijlstra
2015-12-17 2:16 ` Yuyang Du [this message]
2016-01-06 18:49 ` [tip:sched/core] sched/fair: Fix new task' s load avg removed from source CPU in wake_up_new_task() tip-bot for Yuyang Du
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=20151217021637.GK28098@intel.com \
--to=yuyang.du@intel.com \
--cc=Juri.Lelli@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=patrick.bellasi@arm.com \
--cc=peterz@infradead.org \
--cc=steve.muckle@linaro.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.