[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230621172335.33cf0dbb@kernel.org>
Date: Wed, 21 Jun 2023 17:23:35 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Jisheng Zhang <jszhang@...nel.org>
Cc: Giuseppe Cavallaro <peppe.cavallaro@...com>, Alexandre Torgue
<alexandre.torgue@...s.st.com>, Jose Abreu <joabreu@...opsys.com>, "David S
. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Paolo
Abeni <pabeni@...hat.com>, Maxime Coquelin <mcoquelin.stm32@...il.com>,
Chen-Yu Tsai <wens@...e.org>, Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>, netdev@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-sunxi@...ts.linux.dev, Simon Horman <simon.horman@...igine.com>
Subject: Re: [PATCH net-next v3 2/2] net: stmmac: use pcpu 64 bit statistics
where necessary
On Tue, 20 Jun 2023 00:52:20 +0800 Jisheng Zhang wrote:
> +struct stmmac_pcpu_stats {
> + struct u64_stats_sync syncp;
> + /* per queue statistics */
> + struct stmmac_txq_stats txq_stats[MTL_MAX_TX_QUEUES];
> + struct stmmac_rxq_stats rxq_stats[MTL_MAX_RX_QUEUES];
> + /* device stats */
> + u64 rx_packets;
> + u64 rx_bytes;
> + u64 tx_packets;
> + u64 tx_bytes;
> + /* Tx/Rx IRQ Events */
> + u64 tx_pkt_n;
> + u64 rx_pkt_n;
> + u64 normal_irq_n;
> + u64 rx_normal_irq_n;
> + u64 napi_poll;
> + u64 tx_normal_irq_n;
> + u64 tx_clean;
> + u64 tx_set_ic_bit;
> + /* TSO */
> + u64 tx_tso_frames;
> + u64 tx_tso_nfrags;
AFAICT you're using the same structure and syncp for the stats updated
from within IRQ and from xmit and NAPI. That's not safe. The
documentation of u64_stats_sync suggests using _irqsave() variant for
that case but really, I think you should split these stats up.
The statistics which are counting packets / bytes should all go into
respective queue structs, like struct stmmac_tx_queue, and have their
own syncp per context (i.e. separate for xmit and completions if they
can run in parallel).
Having the counters in queue structs is much more common in drivers,
it usually saves memory and allows reporting stats per queue.
You can keep the per-cpu stats for IRQs if there's no IRQ struct,
if you prefer.
--
pw-bot: cr
Powered by blists - more mailing lists