[PATCH v4] virtio: optimize stats counters performance
Stephen Hemminger
stephen at networkplumber.org
Thu Aug 1 01:45:35 CEST 2024
On Wed, 31 Jul 2024 22:58:16 +0000
Morten Brørup <mb at smartsharesystems.com> wrote:
> +
> +static inline void
> +virtio_update_packet_stats(struct virtnet_stats *const stats, const struct rte_mbuf *const mbuf)
> +{
> + uint32_t s = mbuf->pkt_len;
> + const struct rte_ether_addr *ea = rte_pktmbuf_mtod(mbuf, const struct rte_ether_addr *);
> +
> + stats->bytes += s;
> +
> + if (s >= 1024)
> + stats->size_bins[6 + (s > 1518)]++;
> + else if (s <= 64)
> + stats->size_bins[s >> 6]++;
> + else
> + stats->size_bins[32UL - rte_clz32(s) - 5]++;
> +
> + RTE_BUILD_BUG_ON(offsetof(struct virtnet_stats, broadcast) !=
> + offsetof(struct virtnet_stats, multicast) + sizeof(uint64_t));
> + if (unlikely(rte_is_multicast_ether_addr(ea)))
> + (&stats->multicast)[rte_is_broadcast_ether_addr(ea)]++;
> +}
>
Why move it to virtio_rxtx.h it was fine where it was.
More information about the dev
mailing list