From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756740AbcEaIlV (ORCPT ); Tue, 31 May 2016 04:41:21 -0400 Received: from mga02.intel.com ([134.134.136.20]:49526 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756026AbcEaIlS (ORCPT ); Tue, 31 May 2016 04:41:18 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,395,1459839600"; d="scan'208";a="965630011" Date: Tue, 31 May 2016 08:44:00 +0800 From: Yuyang Du To: Vincent Guittot Cc: Peter Zijlstra , Ingo Molnar , linux-kernel , Dietmar Eggemann Subject: Re: [PATCH v3] sched: fix first task of a task group is attached twice Message-ID: <20160531004400.GO18670@intel.com> References: <1464623541-25429-1-git-send-email-vincent.guittot@linaro.org> <20160530194802.GM18670@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 31, 2016 at 09:28:30AM +0200, Vincent Guittot wrote: > Hi Yuyang, > > On 30 May 2016 at 21:48, Yuyang Du wrote: > > On Mon, May 30, 2016 at 05:52:20PM +0200, 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 > >> last_update_time set to 0 and will attached once again during the > >> enqueue. > >> Initialize cfs_rq->avg.last_update_time to 1 instead. > >> > >> 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. > >> + */ > > > > The first time: "once when attaching the task to the group". > > > > That attaching is purely wrong, but will not have any effect (at least > > load/util wise), because the task will later be inited in > > init_entity_runnable_average(). > > This patch is not related to the init of a task but related to the > init of the cfs_rq and to what happen with the 1st task that is > enqueued on it. > > Lets take a task A that has already been scheduled on other cfs_rq so > its se->avg.last_update_time is different from 0. I understand it, finally, :) > Create a new task group TGB > At creation, the cfs_rq->avg.last_update_time of this TGB is set to 0. > > Now move task A on TGB. > A is attached to TGB so se->avg.last_update_time = > cfs_rq->avg.last_update_time which is 0 > A is then enqueued on th cfs_rq and because se->avg.last_update_time > == 0, A will be attached one more time on the cfs_rq > > This patch set cfs_rq->avg.last_update_time to 1 at creation so the > 1st time that A is attached to TGB, se->avg.last_update_time = > cfs_rq->avg.last_update_time = 1 and A will not bve attached one more > time during the enqueue.