From: Peter Zijlstra <peterz@infradead.org>
To: John Stultz <john.stultz@linaro.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
"Dima Zavin" <dima@android.com>, "Ingo Molnar" <mingo@elte.hu>,
"Arve Hjønnevåg" <arve@android.com>
Subject: Re: [PATCH 5/5] sched: use the old min_vruntime when normalizing on dequeue
Date: Sat, 20 Nov 2010 11:55:11 +0100 [thread overview]
Message-ID: <1290250511.2118.7.camel@laptop> (raw)
In-Reply-To: <1290218934-8544-6-git-send-email-john.stultz@linaro.org>
On Fri, 2010-11-19 at 18:08 -0800, John Stultz wrote:
> From: Dima Zavin <dima@android.com>
>
> 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.
>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: Peter Zijlstra <peterz@infradead.org>
> Cc: Arve Hjønnevåg <arve@android.com>
> Signed-off-by: Dima Zavin <dima@android.com>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
> kernel/sched_fair.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
> index f4f6a83..72f19ad 100644
> --- a/kernel/sched_fair.c
> +++ b/kernel/sched_fair.c
> @@ -802,6 +802,8 @@ static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
> static void
> dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
> {
> + u64 min_vruntime;
> +
> /*
> * Update run-time statistics of the 'current'.
> */
> @@ -826,6 +828,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
> if (se != cfs_rq->curr)
> __dequeue_entity(cfs_rq, se);
> account_entity_dequeue(cfs_rq, se);
> +
> + min_vruntime = cfs_rq->min_vruntime;
> update_min_vruntime(cfs_rq);
>
> /*
> @@ -834,7 +838,7 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
> * movement in our normalized position.
> */
> if (!(flags & DEQUEUE_SLEEP))
> - se->vruntime -= cfs_rq->min_vruntime;
> + se->vruntime -= min_vruntime;
> }
Right, so assuming the reasoning is right (my brain still needs to wake
up) the patch is weird, by not simply move the code bock up and avoid
the whole extra variable like so?
---
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 d35f464..dfa28ef 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1003,8 +1003,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, 0);
/*
* Normalize the entity after updating the min_vruntime because the
@@ -1013,6 +1011,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, 0);
}
/*
next prev parent reply other threads:[~2010-11-20 10:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-20 2:08 [PATCH 0/5] [RFC] Trivial scheduler related Android patches John Stultz
2010-11-20 2:08 ` [PATCH 1/5] sched: Enable might_sleep before initializing drivers John Stultz
2010-11-20 10:42 ` Peter Zijlstra
2010-11-20 2:08 ` [PATCH 2/5] sched: make task dump print all 15 chars of proc comm John Stultz
2010-11-23 10:21 ` [tip:sched/core] sched: Make " tip-bot for Erik Gilling
2010-11-20 2:08 ` [PATCH 3/5] scheduler: cpuacct: Enable platform hooks to track cpuusage for CPU frequencies John Stultz
2010-11-20 10:48 ` Peter Zijlstra
2010-11-22 5:51 ` Florian Mickler
2010-11-22 10:43 ` Peter Zijlstra
2010-11-22 12:23 ` Florian Mickler
2010-11-23 2:05 ` Mike Chan
2010-11-23 11:35 ` Peter Zijlstra
2010-11-20 2:08 ` [PATCH 4/5] scheduler: cpuacct: Enable platform callbacks for cpuacct power tracking John Stultz
2010-11-20 2:08 ` [PATCH 5/5] sched: use the old min_vruntime when normalizing on dequeue John Stultz
2010-11-20 10:55 ` Peter Zijlstra [this message]
2010-11-20 12:33 ` 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=1290250511.2118.7.camel@laptop \
--to=peterz@infradead.org \
--cc=arve@android.com \
--cc=dima@android.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox