Re: [PATCH] percpu_counter: Fix __percpu_counter_sum()

Ingo Molnar
2008-12-16T20:17:35Z

* Rusty Russell <rusty@rustcorp.com.au> wrote:

> On Wednesday 10 December 2008 16:19:21 Andrew Morton wrote:
> > Rusty, Christoph: talk to me. If we add a new user of local_t in core
> > kernel, will we regret it?
>
> Interesting. There's new local_t infrastructure, but it's not used.
>
> Here's a benchmark patch showing some results. x86 is pretty close to
> optimal already, though my results on Power show atomic_long is a bad choice
> there.
>
> I'll do an audit of the users, then send out some local_t cleanup patches etc.
>
> Benchmarks for local_t variants
>
> (This patch also fixes the x86 cpu_local_* macros, which are obviously
> unused).
>
> I chose a large array (1M longs) for the inc/add/add_return tests so
> the trivalue case would show some cache pressure.
>
> The cpu_local_inc case is always cache-hot, so it's not comparable to
> the others.
>
> Time in ns per iteration (brackets is with CONFIG_PREEMPT=y):
>
> inc add add_return cpu_local_inc read
> x86-32: 2.13 Ghz Core Duo 2
> atomic_long 118 118 115 17 17
> irqsave/rest 77 78 77 23 16
> trivalue 45 45 127 3(6) 21
> local_t 36 36 36 1(5) 17
>
> x86-64: 2.6 GHz Dual-Core AMD Opteron 2218
> atomic_long 55 60 - 6 19
> irqsave/rest 54 54 - 11 19
> trivalue 47 47 - 5 28
> local_t 47 46 - 1 19

coolness!

>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> arch/x86/include/asm/local.h | 20 ++--
> init/main.c | 198 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 208 insertions(+), 10 deletions(-)

it's a gem - but init/main.c is an arguably pretty sucky place for it.
Stick it somewhere in lib/*, to be moved into testing/* later on?

Ingo