On Thu, 2008-08-21 at 01:10 +1000, Nick Piggin wrote:I had it in sched.c, then moved it to kernel.h and back again, etc.. I'm fine with wherever.. --- Subject: sched: load-balance bias fixes From: Peter Zijlstra <a.p.zijlstra@chello.nl> Date: Wed Aug 20 15:28:51 CEST 2008 Yanmin spotted a regression with my patch that introduces LB_BIAS: commit 93b75217df39e6d75889cc6f8050343286aff4a5 Author: Peter Zijlstra <a.p.zijlstra@chello.nl> Date: Fri Jun 27 13:41:33 2008 +0200 And I just spotted the brainfart - I should have replaced min/max with avg instead of removing it completely. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> --- kernel/sched.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) Index: linux-2.6/kernel/sched.c =================================================================== --- linux-2.6.orig/kernel/sched.c +++ linux-2.6/kernel/sched.c @@ -1996,6 +1996,12 @@ void kick_process(struct task_struct *p) preempt_enable(); } +#define avg(x, y) ({ \ + typeof(x) _avg1 = ((x)+1)/2; \ + typeof(y) _avg2 = ((y)+1)/2; \ + (void) (&_avg1 == &_avg2); \ + _avg1 + _avg2; }) + /* * Return a low guess at the load of a migration-source cpu weighted * according to the scheduling class and "nice" value. @@ -2008,9 +2014,12 @@ static unsigned long source_load(int cpu struct rq *rq = cpu_rq(cpu); unsigned long total = weighted_cpuload(cpu); - if (type == 0 || !sched_feat(LB_BIAS)) + if (type == 0) return total; + if (!sched_feat(LB_BIAS)) + return avg(rq->cpu_load[type-1], total); + return min(rq->cpu_load[type-1], total); } @@ -2023,9 +2032,12 @@ static unsigned long target_load(int cpu struct rq *rq = cpu_rq(cpu); unsigned long total = weighted_cpuload(cpu); - if (type == 0 || !sched_feat(LB_BIAS)) + if (type == 0) return total; + if (!sched_feat(LB_BIAS)) + return avg(rq->cpu_load[type-1], total); + return max(rq->cpu_load[type-1], total); } --
