[PATCH v4] virtio: optimize stats counters performance
Morten Brørup
mb at smartsharesystems.com
Thu Aug 1 01:51:15 CEST 2024
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Thursday, 1 August 2024 01.46
>
> 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.
Because it is also called from the vector implementations [1], where it was not inlined before.
[1]: https://elixir.bootlin.com/dpdk/v24.07/A/ident/virtio_update_packet_stats
More information about the dev
mailing list