Index: MM-2.6.X/kernel/sched.c =================================================================== --- MM-2.6.X.orig/kernel/sched.c 2006-02-12 11:24:48.000000000 +1100 +++ MM-2.6.X/kernel/sched.c 2006-02-12 11:35:40.000000000 +1100 @@ -735,6 +735,19 @@ static inline unsigned long biased_load( { return (wload * NICE_TO_BIAS_PRIO(0)) / SCHED_LOAD_SCALE; } + +/* get the average biased load per runnable task for a run queue */ +static inline unsigned long avg_biased_load(runqueue_t *rq) +{ + /* + * When I'm convinced that this won't be called with a zero nr_running + * and that it can't change during the call this can be simplified. + * For the time being and for proof of concept let's paly it safe. + */ + unsigned long n = rq->nr_running; + + return n ? rq->prio_bias / n : 0; +} #else static inline void set_bias_prio(task_t *p) { @@ -2116,7 +2129,7 @@ find_busiest_group(struct sched_domain * unsigned long tmp; if (max_load - this_load >= SCHED_LOAD_SCALE*2) { - *imbalance = NICE_TO_BIAS_PRIO(0); + *imbalance = avg_biased_load(busiest); return busiest; } @@ -2149,7 +2162,7 @@ find_busiest_group(struct sched_domain * if (pwr_move <= pwr_now) goto out_balanced; - *imbalance = NICE_TO_BIAS_PRIO(0); + *imbalance = avg_biased_load(busiest); return busiest; }