Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934582AbbLQHUz (ORCPT ); Thu, 17 Dec 2015 02:20:55 -0500 Received: from mga01.intel.com ([192.55.52.88]:10409 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934374AbbLQHUx (ORCPT ); Thu, 17 Dec 2015 02:20:53 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,440,1444719600"; d="scan'208";a="873291669" Date: Thu, 17 Dec 2015 07:34:27 +0800 From: Yuyang Du To: Steve Muckle Cc: Peter Zijlstra , Ingo Molnar , Morten Rasmussen , Dietmar Eggemann , Patrick Bellasi , Juri Lelli , Vincent Guittot , "linux-kernel@vger.kernel.org" Subject: Re: PELT initial task load and wake_up_new_task() Message-ID: <20151216233427.GJ28098@intel.com> References: <566B8009.2090006@linaro.org> <20151213191319.GA28098@intel.com> <566F61AA.4020904@linaro.org> <20151215022432.GG28098@intel.com> <56705FE1.5000600@linaro.org> <20151215235556.GI28098@intel.com> <56722303.4070208@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56722303.4070208@linaro.org> 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 Content-Length: 2469 Lines: 71 Hi Steve, On Wed, Dec 16, 2015 at 06:50:43PM -0800, Steve Muckle wrote: > On 12/15/2015 03:55 PM, Yuyang Du wrote: > > Hope the following patch should work. > > Thanks Yuyang. AFAICS it should work, though I believe the test on > last_update_time could instead go at the top of migrate_task_rq_fair()? > It'd save the fn call to remove_entity_load_avg() and two unnecessary > assignments (as p->se.avg.last_update_time and p->se.exec_start = 0 for > newly forked tasks). This worked for me. In a hindsight yesterday, this also occurred to me. But I think the fix is also applicable to a group entity that is being removed but never used. And such cases are not unlikely to happen. To make the code less duplicate, I still do this in remove_entity_load_avg(). Make sense? Sorry about the compile error. --- Subject: [PATCH] sched: Fix new task's load avg removed from source CPU in wake_up_new_task() 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 Signed-off-by: Yuyang Du --- kernel/sched/fair.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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(); -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/