From patchwork Tue May 17 23:21:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 1510 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:52:39 -0000 Delivered-To: patches@linaro.org Received: by 10.224.54.134 with SMTP id q6cs49133qag; Tue, 17 May 2011 16:21:26 -0700 (PDT) Received: by 10.151.93.16 with SMTP id v16mr902602ybl.98.1305674485405; Tue, 17 May 2011 16:21:25 -0700 (PDT) Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx.google.com with ESMTPS id p16si9693959ybk.33.2011.05.17.16.21.24 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 May 2011 16:21:25 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.158 as permitted sender) client-ip=32.97.110.158; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.158 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e37.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4HNIRhG023698; Tue, 17 May 2011 17:18:27 -0600 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4HNLHVq159350; Tue, 17 May 2011 17:21:17 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4HHLHYw019017; Tue, 17 May 2011 11:21:17 -0600 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4HHLGvM019007; Tue, 17 May 2011 11:21:17 -0600 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id A440C1E750E; Tue, 17 May 2011 16:21:16 -0700 (PDT) From: John Stultz To: LKML Cc: Peter Zijlstra , Dima Zavin , John Stultz Subject: [RFC][PATCH] sched: Fix min_vruntime calculation in dequeue_entity Date: Tue, 17 May 2011 16:21:10 -0700 Message-Id: <1305674470-23727-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 From: Peter Zijlstra Peter had sent this patch out in response to a patch from Dima Zavin which tried to address the following issue: "After pulling the thread off the run-queue during a cgroup change, the cfs_rq.min_vruntime gets recalculated. The dequeued thread's vruntime then gets normalized to this new value. This can then lead to the thread getting an unfair boost in the new group if the vruntime of the next task in the old run-queue was way further ahead." Peter suggested the following fix instead. The full thread can be found here: https://lkml.org/lkml/2010/11/20/34 While Dima never replied publicly, I bugged him a few weeks ago and he said that this fix should address his original issue. I just wanted to resend this patch out so the fix was not missed. CC: Dima Zavin CC: Peter Zijlstra Signed-off-by: John Stultz --- kernel/sched_fair.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 6fa833a..fb321dc 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c @@ -1072,8 +1072,6 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) se->on_rq = 0; update_cfs_load(cfs_rq, 0); account_entity_dequeue(cfs_rq, se); - update_min_vruntime(cfs_rq); - update_cfs_shares(cfs_rq); /* * Normalize the entity after updating the min_vruntime because the @@ -1082,6 +1080,9 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) */ if (!(flags & DEQUEUE_SLEEP)) se->vruntime -= cfs_rq->min_vruntime; + + update_min_vruntime(cfs_rq); + update_cfs_shares(cfs_rq); } /*