All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Dima Zavin <dima@android.com>,
	John Stultz <john.stultz@linaro.org>
Subject: [RFC][PATCH] sched: Fix min_vruntime calculation in dequeue_entity
Date: Tue, 17 May 2011 16:21:10 -0700	[thread overview]
Message-ID: <1305674470-23727-1-git-send-email-john.stultz@linaro.org> (raw)

From: Peter Zijlstra <peterz@infradead.org>

Peter had sent this patch out in response to a patch from Dima Zavin
<dima@android.com> 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 <dima@android.com>
CC: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 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);
 }
 
 /*
-- 
1.7.3.2.146.gca209


             reply	other threads:[~2011-05-17 23:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17 23:21 John Stultz [this message]
2011-05-19 11:58 ` [RFC][PATCH] sched: Fix min_vruntime calculation in dequeue_entity Peter Zijlstra
2011-05-19 12:43   ` Mike Galbraith
2011-05-23 19:45   ` Dima Zavin
2011-05-28 16:35 ` [tip:sched/urgent] sched: Fix ->min_vruntime calculation in dequeue_entity() tip-bot for Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305674470-23727-1-git-send-email-john.stultz@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=dima@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.