Re: [PATCH v3 net-next] net-core: add rx_otherhost_dropped counter

From: Jakub Kicinski
Date: Tue Mar 08 2022 - 20:08:54 EST


On Tue, 8 Mar 2022 15:18:25 -0800 Eric Dumazet wrote:
> > that's an expensive packet counter for a common path (e.g., hosting
> > environments).
>
> This was the reason for the initial patch, using SNMP stat, being per cpu.
>
> Adding per-device per-cpu data for this counter will increase cost of
> netdevice dismantle phase,
> and increase time for ndo_get_stats64(), especially on hosts with 256
> or 512 cpus.

Two ways to solve this:
- make dev->pcpu_refcnt point to a structure which holds both
refcnt and whatever stats
- combine these stats into lstats, assuming the netdevs we care
about spawning / destroying fast are sw devices anyway;
struct rtnl_link_ops can indicate to the core if the driver
wants lstats (or just put how many bytes it wants), otherwise
we'd only allocate enough mem for core's stats

Option three - both.