From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, Mike Galbraith <efault@gmx.de>,
Dmitry Adamushko <dmitry.adamushko@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
Subject: [PATCH 2/6] sched: make sched_slice() group scheduling savvy
Date: Wed, 31 Oct 2007 22:10:32 +0100 [thread overview]
Message-ID: <20071031211248.796653000@chello.nl> (raw)
In-Reply-To: 20071031211030.310581000@chello.nl
[-- Attachment #1: sched-slice-group.patch --]
[-- Type: text/plain, Size: 2481 bytes --]
Currently the ideal slice length does not take group scheduling into account.
Change it so that it properly takes all the runnable tasks on this cpu into
account and caluclate the weight according to the grouping hierarchy.
Also fixes a bug in vslice which missed a factor NICE_0_LOAD.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
CC: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
---
kernel/sched_fair.c | 42 +++++++++++++++++++++++++++++++-----------
1 file changed, 31 insertions(+), 11 deletions(-)
Index: linux-2.6/kernel/sched_fair.c
===================================================================
--- linux-2.6.orig/kernel/sched_fair.c
+++ linux-2.6/kernel/sched_fair.c
@@ -331,10 +331,15 @@ static u64 __sched_period(unsigned long
*/
static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
- u64 slice = __sched_period(cfs_rq->nr_running);
+ unsigned long nr_running = rq_of(cfs_rq)->nr_running;
+ u64 slice = __sched_period(nr_running);
- slice *= se->load.weight;
- do_div(slice, cfs_rq->load.weight);
+ for_each_sched_entity(se) {
+ cfs_rq = cfs_rq_of(se);
+
+ slice *= se->load.weight;
+ do_div(slice, cfs_rq->load.weight);
+ }
return slice;
}
@@ -344,24 +349,39 @@ static u64 sched_slice(struct cfs_rq *cf
*
* vs = s/w = p/rw
*/
-static u64 __sched_vslice(unsigned long rq_weight, unsigned long nr_running)
+static u64 __sched_vslice(struct cfs_rq *cfs_rq, struct sched_entity *new)
{
- u64 vslice = __sched_period(nr_running);
+ struct sched_entity *se = cfs_rq->curr;
+ unsigned long nr_running = rq_of(cfs_rq)->nr_running;
+ unsigned long weight = 0;
+ u64 vslice;
+
+ if (new) {
+ nr_running++;
+ weight = new->load.weight;
+ }
- do_div(vslice, rq_weight);
+ vslice = __sched_period(nr_running);
+
+ for_each_sched_entity(se) {
+ cfs_rq = cfs_rq_of(se);
+
+ vslice *= NICE_0_LOAD;
+ do_div(vslice, cfs_rq->load.weight + weight);
+ weight = 0;
+ }
return vslice;
}
-static u64 sched_vslice(struct cfs_rq *cfs_rq)
+static inline u64 sched_vslice(struct cfs_rq *cfs_rq)
{
- return __sched_vslice(cfs_rq->load.weight, cfs_rq->nr_running);
+ return __sched_vslice(cfs_rq, NULL);
}
-static u64 sched_vslice_add(struct cfs_rq *cfs_rq, struct sched_entity *se)
+static inline u64 sched_vslice_add(struct cfs_rq *cfs_rq, struct sched_entity *new)
{
- return __sched_vslice(cfs_rq->load.weight + se->load.weight,
- cfs_rq->nr_running + 1);
+ return __sched_vslice(cfs_rq, new);
}
/*
--
next prev parent reply other threads:[~2007-10-31 21:14 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-31 21:10 [PATCH 0/6] various scheduler patches Peter Zijlstra
2007-10-31 21:10 ` [PATCH 1/6] sched: move the group scheduling primitives around Peter Zijlstra
2007-10-31 21:10 ` Peter Zijlstra [this message]
2007-11-01 11:31 ` [PATCH 2/6] sched: make sched_slice() group scheduling savvy Srivatsa Vaddagiri
2007-11-01 11:51 ` Peter Zijlstra
2007-11-01 11:58 ` Peter Zijlstra
2007-11-01 12:03 ` Peter Zijlstra
2007-11-01 12:20 ` Peter Zijlstra
2007-11-01 16:31 ` Srivatsa Vaddagiri
2007-11-01 16:55 ` Peter Zijlstra
2007-10-31 21:10 ` [PATCH 3/6] sched: high-res preemption tick Peter Zijlstra
2007-10-31 21:53 ` Andi Kleen
2007-10-31 22:04 ` Peter Zijlstra
2007-11-01 10:12 ` Peter Zijlstra
2007-10-31 21:10 ` [PATCH 4/6] sched: sched_rt_entity Peter Zijlstra
2007-10-31 21:10 ` [PATCH 5/6] sched: SCHED_FIFO/SCHED_RR watchdog timer Peter Zijlstra
2007-10-31 21:49 ` Andi Kleen
2007-10-31 22:03 ` Peter Zijlstra
2007-11-03 18:16 ` Andi Kleen
2007-10-31 21:10 ` [PATCH 6/6] sched: place_entity() comments Peter Zijlstra
2007-11-01 8:29 ` [PATCH 0/6] various scheduler patches Ingo Molnar
2007-11-01 10:08 ` 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=20071031211248.796653000@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=dmitry.adamushko@gmail.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=vatsa@linux.vnet.ibm.com \
/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