Re: [PATCH v2 1/2] tg3: Move the [rt]x_dropped counters to tg3_napi

From: Alex Pakhunov
Date: Mon Nov 13 2023 - 12:52:31 EST


Hi,

> Isn't this wrapping artificial? old_stats is of type
> rtnl_link_stats64, so the counters are 64 bit.

The wrapping here is needed as long as tnapi->[rt]x_dropped counters are 32
bit wide. It makes sure the resulting value is correctly wrapped.
tnapi->[rt]x_dropped counters are 32 bit on 32 bit systems to make sure
they can be read atomically.

> Why not use include/linux/u64_stats_sync.h, which should cost you
> nothing on 64 bit machines, and do the right thing on 32 bit machines.

It should be possible to use include/linux/u64_stats_sync.h but it seems
like overkill in this case. First, we mostly care whether the counters are
not zero and/or incremening. We typically don't care about the exact value.
Second, the counters are unlikely to ever reach 4G. Essentially, they are
incremented on memory allocation failures only meaning that the system need
to be in a completely wedged state for a very long time for this to happen.

Given the above additional complexity of u64_stats_sync.h does not seem to
be worth it.

Alex.