diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2008-06-27 07:41:32 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-27 08:31:43 -0400 |
commit | cb5ef42a03a13f95a9ea94e6cda4f7a47497871f (patch) | |
tree | 4c94df72d2889ecce52bf74b141ae06d85d4708a /kernel | |
parent | 051c67640e771fd6ad1b676fc0c16c379b3c6f80 (diff) |
sched: optimize effective_load()
s_i = S * rw_i / \Sum_j rw_j
-> \Sum_j rw_j = S * rw_i / s_i
-> s'_i = S * (rw_i + w) / (\Sum_j rw_j + w)
delta s = s' - s = S * (rw + w) / ((S * rw / s) + w)
= s * (S * (rw + w) / (S * rw + s * w) - 1)
a = S*(rw+w), b = S*rw + s*w
delta s = s * (a-b) / b
IOW, trade one divide for two multiplies
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
Cc: Mike Galbraith <efault@gmx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched_fair.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index a1694441f8b7..0d197be3e3e9 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c | |||
@@ -1082,16 +1082,16 @@ static unsigned long effective_load(struct task_group *tg, long wl, int cpu) | |||
1082 | for_each_sched_entity(se) { | 1082 | for_each_sched_entity(se) { |
1083 | #define D(n) (likely(n) ? (n) : 1) | 1083 | #define D(n) (likely(n) ? (n) : 1) |
1084 | 1084 | ||
1085 | long S, Srw, rw, s, sn; | 1085 | long S, rw, s, a, b; |
1086 | 1086 | ||
1087 | S = se->my_q->tg->shares; | 1087 | S = se->my_q->tg->shares; |
1088 | s = se->my_q->shares; | 1088 | s = se->my_q->shares; |
1089 | rw = se->my_q->load.weight; | 1089 | rw = se->my_q->load.weight; |
1090 | 1090 | ||
1091 | Srw = S * rw / D(s); | 1091 | a = S*(rw + wl); |
1092 | sn = S * (rw + wl) / D(Srw + wg); | 1092 | b = S*rw + s*wg; |
1093 | 1093 | ||
1094 | wl = sn - s; | 1094 | wl = s*(a-b)/D(b); |
1095 | wg = 0; | 1095 | wg = 0; |
1096 | #undef D | 1096 | #undef D |
1097 | } | 1097 | } |