From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753672AbcFPI5d (ORCPT ); Thu, 16 Jun 2016 04:57:33 -0400 Received: from mga03.intel.com ([134.134.136.65]:12440 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751136AbcFPI5a (ORCPT ); Thu, 16 Jun 2016 04:57:30 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,478,1459839600"; d="scan'208";a="998792271" Date: Thu, 16 Jun 2016 09:00:41 +0800 From: Yuyang Du To: Peter Zijlstra Cc: Vincent Guittot , Ingo Molnar , linux-kernel , Mike Galbraith , Benjamin Segall , Paul Turner , Morten Rasmussen , Dietmar Eggemann , Matt Fleming Subject: Re: [PATCH v6 1/4] sched/fair: Fix attaching task sched avgs twice when switching to fair or changing task group Message-ID: <20160616010041.GO8105@intel.com> References: <1465942870-28419-1-git-send-email-yuyang.du@intel.com> <1465942870-28419-2-git-send-email-yuyang.du@intel.com> <20160615152217.GN30921@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160615152217.GN30921@twins.programming.kicks-ass.net> 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 Wed, Jun 15, 2016 at 05:22:17PM +0200, Peter Zijlstra wrote: > On Wed, Jun 15, 2016 at 09:46:53AM +0200, Vincent Guittot wrote: > > I still have concerned with this change of the behavior that attaches > > the task only when it is enqueued. The load avg of the task will not > > be decayed between the time we move it into its new group until its > > enqueue. With this change, a task's load can stay high whereas it has > > slept for the last couple of seconds. Then, its load and utilization > > is no more accounted anywhere in the mean time just because we have > > moved the task which will be enqueued on the same rq. > > A task should always be attached to a cfs_rq and its load/utilization > > should always be accounted on a cfs_rq and decayed for its sleep > > period > > OK; so I think I agree with that. Ok, I agree now. I think the following should fix (or sort out) the attach twice problem Vincent discovered (SMP is needed, maybe move reset() into attach()). static void task_move_group_fair(struct task_struct *p) { detach_task_cfs_rq(p); set_task_rq(p, task_cpu(p)); attach_task_cfs_rq(p); /* * If the cfs_rq's last_update_time is 0, attach the sched avgs * won't be anything useful, as it will be decayed to 0 when any * sched_entity is enqueued to that cfs_rq. * * On the other hand, if the cfs_rq's last_update_time is 0, we * must reset the task's last_update_time to ensure we will attach * the sched avgs when the task is enqueued. */ if (!cfs_rq_of(&p->se)->avg.last_update_time) reset_task_last_update_time(p); else attach_entity_load_avg(cfs_rq_of(&p->se), &p->se); } Vincent, could you please verify? > Does the below (completely untested, > hasn't even been near a compiler) look reasonable? Goodness. But mine is also fired now. :)