[PATCH v5 2/9] ethdev: add common counters for statistics
Stephen Hemminger
stephen at networkplumber.org
Fri May 17 02:19:55 CEST 2024
On Thu, 16 May 2024 18:30:52 +0000
Wathsala Wathawana Vithanage <wathsala.vithanage at arm.com> wrote:
> > + packets = rte_counter64_fetch(&counters->packets);
> > + bytes = rte_counter64_fetch(&counters->bytes);
> > + errors = rte_counter64_fetch(&counters->errors);
> > +
> > + rte_compiler_barrier();
> > +
> > + stats->ipackets += packets;
> > + stats->ibytes += bytes;
> > + stats->ierrors += errors;
> > +
>
> there seems to be a dependency chain in the above loads and subsequent stores.
> If that's the case what's the purpose of the compiler barrier?
>
> --wathsala
It is so that the counters returned per queue are the same as the
count across all queues. A really annoying compiler could in the
process of inlining everything on 64 bit, decide that it didn't need
to have these temporary variables. It could read counters->packets
twice, once for the total and once for the per-queue values. In the
intervening window, the PMD could have received another packet.
This is a pre-existing purely theoretical bug across all these
drivers. The Linux kernel has started using tools to find these.
More information about the dev
mailing list