Re: [PATCH 16/17] fs: Convert nr_inodes to a per-cpu counter

From: Eric Dumazet
Date: Sat Oct 16 2010 - 05:31:32 EST


Le samedi 16 octobre 2010 Ã 02:07 -0700, Andrew Morton a Ãcrit :
> On Sat, 16 Oct 2010 10:29:08 +0200 Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote:
> > Some people believe percpu_counter object is the right answer to such
> > distributed counters, because the loop is done on 'online' cpus instead
> > of 'possible' cpus. "It must be better if number of possible cpus is
> > 4096 and only one or two cpus are online"...
> >
> > But if we do this loop only on rare events, like
> > "cat /proc/sys/fs/inode-nr", then the percpu_counter() is more
> > expensive, because percpu_add() _is_ more expensive :
> >
> > - Its a function call and lot of instructions/cycles per call, while
> > this_cpu_inc(nr_inodes) is a single instruction, using no register on
> > x86.
>
> You want an inlined percpu_counter_inc() then write one! Bonus points
> for writing this_cpu_add_return() and doing it without a
> preempt_disable(). It collapses to just a few instructions.
>

A few instructions, but no guarantee of false sharing eviction.

Each time one cpu dirties the percpu_counter object, it slow down other
cpus because they need to fetch the cache line again.

Btw, I believe my previous patch against include/linux/percpu_counter.h
was lost. Are you sure I am the right guy to work on percpu_counter
infra ? If yes I can implement your inlined idea.

Thanks


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