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>,
Yuyang Du <yuyang.du@intel.com>
Subject: Re: [PATCH v3] sched: fix first task of a task group is attached twice
Date: Wed, 1 Jun 2016 17:54:17 +0200 [thread overview]
Message-ID: <CAKfTPtD401C5_DTPPCMDmV87y2r5sG_066drJQtaFN5-G+9bsA@mail.gmail.com> (raw)
In-Reply-To: <574EFFBD.5060803@arm.com>
On 1 June 2016 at 17:31, Dietmar Eggemann <dietmar.eggemann@arm.com> wrote:
> On 30/05/16 16:52, Vincent Guittot wrote:
>> The cfs_rq->avg.last_update_time is initialize to 0 with the main effect
>> that the 1st sched_entity that will be attached, will keep its
>
> attached in .task_move_group ?
>
> I'm not sure if we can have a .switched_to() directly followed by a
> .enqueue_task() into a cfs_rq with avg.last_update_time = 0.
I think it can happen as well if the task is not queued during the
change of scheduling class because when we attach the task in
switched_to, the task->se.avg.last_update_time will stay to 0. So when
the task will be enqueued, it will be attached one more time
>
>> last_update_time set to 0 and will attached once again during the
>> enqueue.
>> Initialize cfs_rq->avg.last_update_time to 1 instead.
>
> Maybe worth mentioning in the header:
>
> This double se attaching for the first task which moves into the task
> group owning this cfs_rq (.task_move_group() and .enqueue_task()) can
> (obviously) only happen if CONFIG_FAIR_GROUP_SCHED is set.
>
> The reason for this is that we set 'se->avg.last_update_time =
> cfs_rq->avg.last_update_time' in attach_entity_load_avg() and use
> 'migrated = !sa->last_update_time' as a flag in
> enqueue_entity_load_avg() to decide if we call attach_entity_load_avg()
> (again) or only update se->avg .
>
> Tested-by: Dietmar Eggemann <Dietmar.Eggemann@arm.com>
Thanks
>
>> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
>> ---
>>
>> v3:
>> - add initialization of load_last_update_time_copy for not 64bits system
>> - move init into init_cfs_rq
>>
>> v2:
>> - rq_clock_task(rq_of(cfs_rq)) can't be used because lock is not held
>>
>> kernel/sched/fair.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 218f8e8..86be9c1 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -8459,6 +8459,16 @@ void init_cfs_rq(struct cfs_rq *cfs_rq)
>> cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime;
>> #endif
>> #ifdef CONFIG_SMP
>> + /*
>> + * Set last_update_time to something different from 0 to make
>> + * sure the 1st sched_entity will not be attached twice: once
>> + * when attaching the task to the group and one more time when
>> + * enqueueing the task.
>> + */
>> + cfs_rq->avg.last_update_time = 1;
>> +#ifndef CONFIG_64BIT
>> + cfs_rq->load_last_update_time_copy = 1;
>> +#endif
>> atomic_long_set(&cfs_rq->removed_load_avg, 0);
>> atomic_long_set(&cfs_rq->removed_util_avg, 0);
>> #endif
next prev parent reply other threads:[~2016-06-01 15:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 13:08 [PATCH] sched: fix first task of a task group is attached twice Vincent Guittot
2016-05-25 15:01 ` [PATCH v2] " Vincent Guittot
2016-05-25 22:38 ` Yuyang Du
2016-05-26 8:26 ` Vincent Guittot
2016-05-26 0:40 ` Yuyang Du
2016-05-26 8:51 ` Vincent Guittot
2016-05-27 15:48 ` Dietmar Eggemann
2016-05-27 17:16 ` Vincent Guittot
2016-05-27 20:38 ` Dietmar Eggemann
2016-05-30 7:04 ` Vincent Guittot
2016-05-30 15:52 ` [PATCH v3] " Vincent Guittot
2016-05-30 19:48 ` Yuyang Du
2016-05-31 7:28 ` Vincent Guittot
2016-05-31 0:44 ` Yuyang Du
2016-06-01 15:31 ` Dietmar Eggemann
2016-06-01 15:54 ` Vincent Guittot [this message]
2016-06-06 19:32 ` Dietmar Eggemann
2016-06-07 7:35 ` Vincent Guittot
2016-06-15 19:19 ` Yuyang Du
2016-06-16 7:12 ` Vincent Guittot
2016-06-15 23:24 ` Yuyang Du
2016-06-16 9:42 ` Vincent Guittot
2016-05-30 15:54 ` [PATCH v2] " 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=CAKfTPtD401C5_DTPPCMDmV87y2r5sG_066drJQtaFN5-G+9bsA@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=yuyang.du@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;
as well as URLs for NNTP newsgroup(s).