From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161889AbcFAPbP (ORCPT ); Wed, 1 Jun 2016 11:31:15 -0400 Received: from foss.arm.com ([217.140.101.70]:38683 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755407AbcFAPbM (ORCPT ); Wed, 1 Jun 2016 11:31:12 -0400 Subject: Re: [PATCH v3] sched: fix first task of a task group is attached twice To: Vincent Guittot , peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org References: <1464623541-25429-1-git-send-email-vincent.guittot@linaro.org> Cc: yuyang.du@intel.com From: Dietmar Eggemann Message-ID: <574EFFBD.5060803@arm.com> Date: Wed, 1 Jun 2016 16:31:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1464623541-25429-1-git-send-email-vincent.guittot@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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 > Signed-off-by: Vincent Guittot > --- > > 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