virtio-net: fix total qstat values
Subsystems (4)
Jakub Kicinski
maintainercover virtio-net: fix total qstat values
Another small fix discovered after we enabled virtio multi-queue in netdev CI. The queue stat test fails:
# Exception| Exception: Qstats are lower, fetched later not ok 3 stats.pkt_byte_sum
The queue stats from disabled queues are supposed to be reported in the "base" stats.
Jakub Kicinski (2):
net: export a helper for adding up queue stats
virtio-net: fix total qstat values
include/net/netdev_queues.h | 6 ++++ drivers/net/virtio_net.c | 4 +++ net/core/netdev-genl.c | 69 +++++++++++++++++++++++++++---------- 3 files changed, 60 insertions(+), 19 deletions(-)
Signature · 1 line
2.49.0
Jakub Kicinski
maintainerPATCH 1/2 net: export a helper for adding up queue stats
Older drivers and drivers with lower queue counts often have a static array of queues, rather than allocating structs for each queue on demand. Add a helper for adding up qstats from a queue range. Expectation is that driver will pass a queue range [netdev->real_num_*x_queues, MAX). It was tempting to always use num_*x_queues as the end, but virtio seems to clamp its queue count after allocating the netdev. And this way we can trivaly reuse the helper for [0, real_..).
--- include/net/netdev_queues.h | 6 ++++ net/core/netdev-genl.c | 69 +++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 19 deletions(-)
include/net/netdev_queues.h +6 -0
@@ -105,6 +105,12 @@ struct netdev_stat_ops { struct netdev_queue_stats_tx *tx); }; +void netdev_stat_queue_sum (struct net_device *netdev, +int rx_start,int rx_end, +struct netdev_queue_stats_rx *rx_sum, +int tx_start,int tx_end, +struct netdev_queue_stats_tx *tx_sum); +/** * struct netdev_queue_mgmt_ops - netdev ops for queue management *
net/core/netdev-genl.c +50 -19
93 lines not on this page · raw message
Signature · 1 line
2.49.0
Jakub Kicinski
maintainerPATCH 2/2 virtio-net: fix total qstat values
In reply to Jakub KicinskiNIPA tests report that the interface statistics reported via qstat are lower than those reported via ip link. Looks like this is because some tests flip the queue count up and down, and we end up with some of the traffic accounted on disabled queues.
Add up counters from disabled queues.
--- drivers/net/virtio_net.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/virtio_net.c +4 -0
@@ -5678,6 +5678,10 @@ static void virtnet_get_base_stats(struct net_device *dev,if (vi->device_stats_cap &VIRTIO_NET_STATS_TYPE_TX_SPEED ) tx->hw_drop_ratelimits =0 ; + +netdev_stat_queue_sum (dev, + dev->real_num_rx_queues, vi->max_queue_pairs, rx, + dev->real_num_tx_queues, vi->max_queue_pairs, tx); }static const struct netdev_stat_ops virtnet_stat_ops = {
Signature · 1 line
2.49.0
This series was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Tue, 6 May 2025 17:32:19 -0700 you wrote:
Another small fix discovered after we enabled virtio multi-queue in netdev CI. The queue stat test fails:
# Exception| Exception: Qstats are lower, fetched later not ok 3 stats.pkt_byte_sum
The queue stats from disabled queues are supposed to be reported in the "base" stats.
[...]
Here is the summary with links:
- [net,1/2] net: export a helper for adding up queue stats
https://git.kernel.org/netdev/net/c/23fa6a23d971 - [net,2/2] virtio-net: fix total qstat values https://git.kernel.org/netdev/net/c/001160ec8c59
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html