hv_netvsc: use per_cpu stats to calculate TX/RX data
Subsystems (3)
PATCH v2 1/1 hv_netvsc: use per_cpu stats to calculate TX/RX data
Current code does not lock anything when calculating the TX and RX stats. As a result, the RX and TX data reported by ifconfig are not accuracy in a system with high network throughput and multiple CPUs (in my test, RX/TX = 83% between 2 HyperV VM nodes which have 8 vCPUs and 40G Ethernet).
This patch fixed the above issue by using per_cpu stats. netvsc_get_stats64() summarizes TX and RX data by iterating over all CPUs to get their respective stats.
This v2 patch addressed David's comments on the cleanup path when netdev_alloc_pcpu_stats() failed.
--- drivers/net/hyperv/hyperv_net.h | 9 +++++ drivers/net/hyperv/netvsc_drv.c | 85 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 86 insertions(+), 8 deletions(-)
drivers/net/hyperv/hyperv_net.h +9 -0
@@ -611,6 +611,12 @@ struct multi_send_data {u32 count;/* counter of batched packets */ }; +struct netvsc_stats { +u64 packets; +u64 bytes; +struct u64_stats_sync s_sync; +}; +/* The context of the netvsc device */ struct net_device_context {/* point back to our device context */
@@ -618,6 +624,9 @@ struct net_device_context {struct delayed_work dwork;struct work_struct work;u32 msg_enable;/* debug level */ + +struct netvsc_stats __percpu *tx_stats; +struct netvsc_stats __percpu *rx_stats; };/* Per netvsc device */
drivers/net/hyperv/netvsc_drv.c +77 -8
158 lines not on this page · raw message
Signature · 1 line
1.8.5.2
From: Simon Xiao <[email protected]>
Date: Thu, 14 May 2015 01:00:25 -0700
Quoted 9 lines
Current code does not lock anything when calculating the TX and RX stats. As a result, the RX and TX data reported by ifconfig are not accuracy in a system with high network throughput and multiple CPUs (in my test, RX/TX = 83% between 2 HyperV VM nodes which have 8 vCPUs and 40G Ethernet).
This patch fixed the above issue by using
per_cpustats.netvsc_get_stats64()summarizes TX and RX data by iterating over all CPUs to get their respective stats.
Quoted 6 lines
This v2 patch addressed David's comments on the cleanup path when
netdev_alloc_pcpu_stats()failed.Signed-off-by Simon Xiao <[email protected]>Reviewed-by K. Y. Srinivasan <[email protected]>Reviewed-by Haiyang Zhang <[email protected]>
Applied, thanks.