Re: [PATCH net v6 1/4] octeon_ep: update tx/rx stats locally for persistence

From: Jakub Kicinski
Date: Mon Jan 13 2025 - 22:37:08 EST


On Fri, 10 Jan 2025 04:27:27 -0800 Shinas Rasheed wrote:
> @@ -991,33 +991,30 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb,
> static void octep_get_stats64(struct net_device *netdev,
> struct rtnl_link_stats64 *stats)
> {
> - u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
> struct octep_device *oct = netdev_priv(netdev);
> int q;
>
> + oct->iface_tx_stats.pkts = 0;
> + oct->iface_tx_stats.octs = 0;
> + oct->iface_rx_stats.pkts = 0;
> + oct->iface_rx_stats.octets = 0;
> + for (q = 0; q < oct->num_ioq_stats; q++) {
> + oct->iface_tx_stats.pkts += oct->stats_iq[q].instr_completed;
> + oct->iface_tx_stats.octs += oct->stats_iq[q].bytes_sent;
> + oct->iface_rx_stats.pkts += oct->stats_oq[q].packets;
> + oct->iface_rx_stats.octets += oct->stats_oq[q].bytes;
> + }

The new approach is much better, but you can't use oct->iface_* as
intermediate storage. There is no exclusive locking on this function,
multiple processes can be executing this function in parallel.
Overwriting each others updates to oct->iface_tx_stats etc.
--
pw-bot: cr