On 9/6/25 07:59, Jakub Kicinski wrote:
On Sat, 6 Sep 2025 00:35:37 +0800 Vivian Wang wrote:
quoted
quoted
quoted
On a closer look, these counters in ndev->stats seems to be redundant
with the hardware-tracked statistics, so maybe I should just not bother
with updating ndev->stats. Does that make sense?
For rx/tx packets/bytes I think that makes sense.
But what about rx/tx drops?
Right... but tstats doesn't have *_dropped. It seems that tx_dropped and
rx_dropped are considered "slow path" for real devices. It makes sense
to me that those should be very rare.
Pretty sure Simon meant the per-cpu netdev stats in general.
There are three types of them, if you need drops I think you
probably want dstats. Take a look.
According to this comment in net/core/dev.c dev_get_stats():
/*
* IPv{4,6} and udp tunnels share common stat helpers and use
* different stat type (NETDEV_PCPU_STAT_TSTATS vs
* NETDEV_PCPU_STAT_DSTATS). Ensure the accounting is consistent.
*/
"dstats" is meant for tunnels. This doesn't look like the right thing to
use, and no other pcpu_stat_type gives me tx_dropped. Do you think I
should use dstats anyway?
(And yes the only software-tracked one should be tx_dropped. Since we
pre-allocate the RX buffers, there is no opportunity to drop on RX in
software.)