Re: [PATCH net-next-2.6] bridge: 64bit rx/tx counters

Eric Dumazet
2010-08-12T12:16:21Z

Le lundi 09 août 2010 à 21:47 -0700, Andrew Morton a écrit :

> Oh for fuck's sake. Will you guys just stop adding generic kernel
> infrastructure behind everyone's backs?
>
> Had I actually been aware that this stuff was going into the tree I'd
> have pointed out that the u64_stats_* api needs renaming.
> s/stats/counter/ because it has no business assuming that the counter
> is being used for statistics.
>
>

Sure. Someone suggested to change the name, considering values could
also be signed (s64 instead of u64_...)

> And all this open-coded per-cpu counter stuff added all over the place.
> Were percpu_counters tested or reviewed and found inadequate and unfixable?
> If so, please do tell.
>

percpu_counters tries hard to maintain a view of the current value of
the (global) counter. This adds a cost because of a shared cache line
and locking. (__percpu_counter_sum() is not very scalable on big hosts,
it locks the percpu_counter lock for a possibly long iteration)

For network stats we dont want to maintain this central value, we do the
folding only when necessary. And this folding has zero effect on
concurrent writers (counter updates)

For network stack, we also need to update two values, a packet counter
and a bytes counter. percpu_counter is not very good for the 'bytes
counter', since we would have to use a arbitrary big bias value.
Using several percpu_counter would also probably use more cache lines.

Also please note this stuff is only needed for 32bit arches.

Using percpu_counter would slow down network stack on modern arches.

I am very well aware of the percpu_counter stuff, I believe I tried to
optimize it a bit in the past.

Thanks