[PATCH 2/2] sched: fair: fix calc_delta_asym

From: Peter Zijlstra
Date: Fri Feb 15 2008 - 06:23:49 EST


The goal of calc_delta_asym() is to be asymetrically around NICE_0_LOAD, in
that it favours >=0 over <0. The current implementation does not achieve that.

-20 |
|
0 --------+-------
.'
19 .'

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
kernel/sched_fair.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

Index: linux-2.6/kernel/sched_fair.c
===================================================================
--- linux-2.6.orig/kernel/sched_fair.c
+++ linux-2.6/kernel/sched_fair.c
@@ -417,12 +417,17 @@ calc_delta_fair(unsigned long delta, str
static inline unsigned long
calc_delta_asym(unsigned long delta, struct sched_entity *se)
{
- unsigned long fair = calc_delta_fair(delta, se);
+ if (se->load.weight < NICE_0_LOAD) {
+ struct load_weight lw = {
+ .weight = NICE_0_LOAD,
+ .inv_weight = 1UL << (WMULT_SHIFT-NICE_0_SHIFT)
+ };

- if (fair > delta)
- fair = delta;
+ delta = calc_delta_mine(delta, cfs_rq_of(se)->load.weight, &lw);
+ se = parent_entity(se);
+ }

- return fair;
+ return calc_delta_fair(delta, se);
}

/*

--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/