Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753108AbbHTX5M (ORCPT ); Thu, 20 Aug 2015 19:57:12 -0400 Received: from lgeamrelo01.lge.com ([156.147.1.125]:48613 "EHLO lgeamrelo01.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751942AbbHTX5K (ORCPT ); Thu, 20 Aug 2015 19:57:10 -0400 X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Fri, 21 Aug 2015 08:56:30 +0900 From: Byungchul Park To: Peter Zijlstra , yuyang.du@intel.com Cc: mingo@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 4/5] sched: sync a se with its cfs_rq when switching sched class to fair class Message-ID: <20150820235630.GK24261@byungchulpark-X58A-UD3R> References: <1439966836-11266-1-git-send-email-byungchul.park@lge.com> <1439966836-11266-5-git-send-email-byungchul.park@lge.com> <20150819171241.GQ20948@worktop> <20150819201106.GA27777@intel.com> <20150820211323.GD3161@worktop.event.rightround.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150820211323.GD3161@worktop.event.rightround.com> 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: 2859 Lines: 67 On Thu, Aug 20, 2015 at 11:13:23PM +0200, Peter Zijlstra wrote: > On Thu, Aug 20, 2015 at 04:11:06AM +0800, Yuyang Du wrote: > > On Wed, Aug 19, 2015 at 07:12:41PM +0200, Peter Zijlstra wrote: > > > On Wed, Aug 19, 2015 at 03:47:15PM +0900, byungchul.park@lge.com wrote: > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > > > index 1be042a..3419f6c 100644 > > > > --- a/kernel/sched/fair.c > > > > +++ b/kernel/sched/fair.c > > > > @@ -2711,6 +2711,17 @@ static inline void update_load_avg(struct sched_entity *se, int update_tg) > > > > > > > > static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) > > > > { > > > > + /* > > > > + * in case of migration and cgroup-change, more care should be taken > > > > + * because se's cfs_rq was changed, that means calling __update_load_avg > > > > + * with new cfs_rq->avg.last_update_time is meaningless. so we skip the > > > > + * update here. we have to update it with prev cfs_rq just before changing > > > > + * se's cfs_rq, and get here soon. > > > > + */ > > > > + if (se->avg.last_update_time) > > > > + __update_load_avg(cfs_rq->avg.last_update_time, cpu_of(rq_of(cfs_rq)), > > > > + &se->avg, 0, 0, NULL); > > > > + > > > > se->avg.last_update_time = cfs_rq->avg.last_update_time; > > > > cfs_rq->avg.load_avg += se->avg.load_avg; > > > > cfs_rq->avg.load_sum += se->avg.load_sum; > > > > > > you seem to have forgotten to remove the same logic from > > > enqueue_entity_load_avg(), which will now call __update_load_avg() > > > twice. > > > > In case of enqueue_entity_load_avg(), that seems to be ok. > > > > However, the problem is that he made it "entangled": > > > > In enqueue_entity_load_avg(): > > > > if (migrated) > > attach_entity_load_avg(); > > > > while in attach_entity_load_avg(): > > > > if (!migrated) > > __update_load_avg(); > > > > so, if attach() is called from enqueue(), that if() is never true. > > Right, I noticed the same yesterday when I took a second look at that > stuff. It was a little confusing indeed. don't couple functions to each other between functions. i believe it's acceptable if you look at each function itself. in other words, attach_entity_load_avg() must call __update_load_avg() with the condition, whoever calls attach_entity_load_avg(). and enqueue_entity_load_avg(), too. > -- > 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/ -- 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/