Skip to content

Commit

Permalink
sched: Update effective_load() to use global share weights
Browse files Browse the repository at this point in the history
Previously effective_load would approximate the global load weight present on
a group taking advantage of:

entity_weight = tg->shares ( lw / global_lw ), where entity_weight was provided
by tg_shares_up.

This worked (approximately) for an 'empty' (at tg level) cpu since we would
place boost load representative of what a newly woken task would receive.

However, now that load is instantaneously updated this assumption is no longer
true and the load calculation is rather incorrect in this case.

Fix this (and improve the general case) by re-writing effective_load to take
advantage of the new shares distribution code.

Signed-off-by: Paul Turner <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
paulturner authored and Ingo Molnar committed Jan 18, 2011
1 parent c9b5f50 commit 977dda7
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -1362,27 +1362,27 @@ static long effective_load(struct task_group *tg, int cpu, long wl, long wg)
return wl;

for_each_sched_entity(se) {
long S, rw, s, a, b;
long lw, w;

S = se->my_q->tg->shares;
s = se->load.weight;
rw = se->my_q->load.weight;
tg = se->my_q->tg;
w = se->my_q->load.weight;

a = S*(rw + wl);
b = S*rw + s*wg;
/* use this cpu's instantaneous contribution */
lw = atomic_read(&tg->load_weight);
lw -= se->my_q->load_contribution;
lw += w + wg;

wl = s*(a-b);
wl += w;

if (likely(b))
wl /= b;
if (lw > 0 && wl < lw)
wl = (wl * tg->shares) / lw;
else
wl = tg->shares;

/*
* Assume the group is already running and will
* thus already be accounted for in the weight.
*
* That is, moving shares between CPUs, does not
* alter the group weight.
*/
/* zero point is MIN_SHARES */
if (wl < MIN_SHARES)
wl = MIN_SHARES;
wl -= se->load.weight;
wg = 0;
}

Expand Down

0 comments on commit 977dda7

Please sign in to comment.