Re: VolanoMark regression with 2.6.27-rc1

From: Peter Zijlstra
Date: Wed Aug 20 2008 - 11:15:54 EST


On Thu, 2008-08-21 at 01:10 +1000, Nick Piggin wrote:
> On Thursday 21 August 2008 00:33, Peter Zijlstra wrote:
> > On Wed, 2008-08-20 at 18:32 +0400, adobriyan@xxxxxxxxx wrote:
> > > On Wed, Aug 20, 2008 at 03:32:17PM +0200, Peter Zijlstra wrote:
>
> > > > +#define avg(x, y) ({ \
> > > > + typeof(x) _avg1 = ((x)+1)/2; \
> > > > + typeof(x) _avg2 = ((y)+1)/2; \
> > >
> > > ITYM, typeof(y)
> >
> > you thought right, I did mean that :-)
> >
> > > > + (void) (&_avg1 == &_avg2); \
> > > > + _avg1 + _avg2; })
>
> I don't think this implementation of avg should go in kernel.h?
>
> It gives an average of 1 and 1 to be 2, 3 and 3 is 4, 1 and 3 is
> 3 etc.
>
> Maybe it is reasonable for very high numbers that would overflow
> if added first, but it doesn't seem reasonable for a generic
> averaging function.

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@xxxxxxxxx>
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@xxxxxxxxx>
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@xxxxxxxxx>
---
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);
}



--
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/