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>
This commit is contained in:
parent
051c67640e
commit
cb5ef42a03
1 changed files with 4 additions and 4 deletions
|
@ -1082,16 +1082,16 @@ static unsigned long effective_load(struct task_group *tg, long wl, int cpu)
|
||||||
for_each_sched_entity(se) {
|
for_each_sched_entity(se) {
|
||||||
#define D(n) (likely(n) ? (n) : 1)
|
#define D(n) (likely(n) ? (n) : 1)
|
||||||
|
|
||||||
long S, Srw, rw, s, sn;
|
long S, rw, s, a, b;
|
||||||
|
|
||||||
S = se->my_q->tg->shares;
|
S = se->my_q->tg->shares;
|
||||||
s = se->my_q->shares;
|
s = se->my_q->shares;
|
||||||
rw = se->my_q->load.weight;
|
rw = se->my_q->load.weight;
|
||||||
|
|
||||||
Srw = S * rw / D(s);
|
a = S*(rw + wl);
|
||||||
sn = S * (rw + wl) / D(Srw + wg);
|
b = S*rw + s*wg;
|
||||||
|
|
||||||
wl = sn - s;
|
wl = s*(a-b)/D(b);
|
||||||
wg = 0;
|
wg = 0;
|
||||||
#undef D
|
#undef D
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue