From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754099AbcIONS2 (ORCPT ); Thu, 15 Sep 2016 09:18:28 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:59073 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754667AbcIONSQ (ORCPT ); Thu, 15 Sep 2016 09:18:16 -0400 Date: Thu, 15 Sep 2016 15:18:07 +0200 From: Peter Zijlstra To: Vincent Guittot Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, yuyang.du@intel.com, Morten.Rasmussen@arm.com, linaro-kernel@lists.linaro.org, dietmar.eggemann@arm.com, pjt@google.com, bsegall@google.com Subject: Re: [PATCH 7/7 v3] sched: fix wrong utilization accounting when switching to fair class Message-ID: <20160915131807.GS5008@twins.programming.kicks-ass.net> References: <1473666472-13749-1-git-send-email-vincent.guittot@linaro.org> <1473666472-13749-8-git-send-email-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1473666472-13749-8-git-send-email-vincent.guittot@linaro.org> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 12, 2016 at 09:47:52AM +0200, Vincent Guittot wrote: > When a task switches to fair scheduling class, the period between now and > the last update of its utilization is accounted as running time whatever > happened during this period. This wrong accounting applies to the task > and also to the task group branch. > > When changing the property of a running task like its list of allowed CPUs > or its scheduling class, we follow the sequence: > -dequeue task > -put task > -change the property > -set task as current task > -enqueue task > > The end of the sequence doesn't follow the normal sequence which is : > -enqueue a task > -then set the task as current task. > > This wrong ordering is the root cause of wrong utilization accounting. > Update the sequence to follow the right one: > -dequeue task > -put task > -change the property > -enqueue task > -set task as current task But enqueue_entity depends on cfs_rq->curr, which is set by set_curr_task_fair(). Also, the normalize comment in dequeue_entity() worries me, 'someone' didn't update that when he moved update_min_vruntime() around.