ice: Reset stats on queue change
Subsystems (2)
PATCH 1/1 ice: Reset stats on queue change
Commit 288ecf491b16 ("ice: Accumulate ring statistics over reset") implemented functionality for interface statistics to persist over reset. This avoided the case where a reset happens in the background, statistics set to zero, and the user checks ring statistics expecting them to be populated.
In the case of changing the number of queues, statistics should reset. This is because old data should clear after parameter reconfiguration.
Fix this by resetting statistics when the number of queues changes.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
drivers/net/ethernet/intel/ice/ice_lib.c +65 -0
@@ -1683,6 +1683,67 @@ static int ice_vsi_alloc_ring_stats(struct ice_vsi *vsi)return -ENOMEM ; } +/** +* ice_reset_tx_ring_stats - Reset all Tx ring stats of a given ring +* @tx_ring: the ring whose stats needs to be cleared +*/ +static void ice_reset_tx_ring_stats (struct ice_tx_ring *tx_ring) +{ +struct ice_ring_stats *ring_stats; + + ring_stats = tx_ring->ring_stats; +if (!ring_stats) +return ; + +memset (&ring_stats->stats,0 , +sizeof (ring_stats->stats)); +memset (&ring_stats->tx_stats,0 , +sizeof (ring_stats->tx_stats)); + ring_stats->tx_stats.prev_pkt =-1 ; +} + +/** +* ice_reset_rx_ring_stats - Reset all Rx ring stats of a given ring +* @rx_ring: the ring whose stats needs to be cleared +*/ +static void ice_reset_rx_ring_stats (struct ice_rx_ring *rx_ring) +{ +struct ice_ring_stats *ring_stats; + + ring_stats = rx_ring->ring_stats; +if (!ring_stats) +return ; + +memset (&ring_stats->stats,0 , +sizeof (ring_stats->stats)); +memset (&ring_stats->rx_stats,0 , +sizeof (ring_stats->rx_stats)); +} + +/** +* ice_vsi_reset_stats - Reset all stats of a given VSI +* @vsi: the VSI whose stats needs to be cleared +*/ +static void ice_vsi_reset_stats (struct ice_vsi *vsi) +{ +int i; + +if (vsi->type ==ICE_VSI_CHNL ) +return ; + +memset (&vsi->net_stats,0 ,sizeof (vsi->net_stats)); +memset (&vsi->eth_stats,0 ,sizeof (vsi->eth_stats)); +memset (&vsi->eth_stats_prev,0 ,sizeof (vsi->eth_stats_prev)); + +ice_for_each_txq (vsi, i) +ice_reset_tx_ring_stats (vsi->tx_rings[i]); + +ice_for_each_rxq (vsi, i) +ice_reset_rx_ring_stats (vsi->rx_rings[i]); + + vsi->stat_offsets_loaded = false; +} +/** * ice_vsi_manage_rss_lut - disable/enable RSS * @vsi: the VSI being changed
@@ -3608,6 +3669,10 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)if (ice_vsi_realloc_stat_arrays (vsi, prev_txq, prev_rxq)) goto err_vectors; +/* Reset stats if queues changed */ +if (vsi->num_txq != prev_txq || vsi->num_rxq != prev_rxq) +ice_vsi_reset_stats (vsi); +ice_vsi_rebuild_set_coalesce (vsi, coalesce, prev_num_q_vectors);kfree (coalesce);
Signature · 6 lines
2.34.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
From: Benjamin Mikailenko <[email protected]>
Date: Tue, 20 Dec 2022 11:05:06 -0500
Quoted 8 lines
Commit
288ecf491b16("ice: Accumulate ring statistics over reset") implemented functionality for interface statistics to persist over reset. This avoided the case where a reset happens in the background, statistics set to zero, and the user checks ring statistics expecting them to be populated.In the case of changing the number of queues, statistics should reset. This is because old data should clear after parameter reconfiguration.
"Should clear" -- because? Who said that? Stats are usually a netdev-lifetime entity (or even pcidev-lifetime).
Quoted 4 lines
Fix this by resetting statistics when the number of queues changes.
Fixes 288ecf491b16 ("ice: Accumulate ring statistics over reset")
It's not even clear why resets are needed, not speaking of if it actually fixes anything. I think this wouldn't hit the net-fixes tree with no real scenario where the mentioned commit provides a serious regression.
Quoted 4 lines
Signed-off-by Benjamin Mikailenko <[email protected]>--- drivers/net/ethernet/intel/ice/ice_lib.c | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
[...]
Quoted 2 lines
Signature · 1 line
2.34.3
Thanks,
Olek
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 16 lines · Alexander Lobakin
From: Benjamin Mikailenko <[email protected]>
Date: Tue, 20 Dec 2022 11:05:06 -0500Quoted 8 lines
Commit
288ecf491b16("ice: Accumulate ring statistics over reset") implemented functionality for interface statistics to persist over reset. This avoided the case where a reset happens in the background, statistics set to zero, and the user checks ring statistics expecting them to be populated.In the case of changing the number of queues, statistics should reset. This is because old data should clear after parameter reconfiguration.
"Should clear" -- because? Who said that? Stats are usually a netdev-lifetime entity (or even pcidev-lifetime).
Quoted 1 line
Quoted 9 lines
Quoted 3 lines
Fix this by resetting statistics when the number of queues changes.
Fixes 288ecf491b16 ("ice: Accumulate ring statistics over reset")It's not even clear why resets are needed, not speaking of if it actually fixes anything. I think this wouldn't hit the net-fixes tree with no real scenario where the mentioned commit provides a serious regression.
Hello Olek, thanks for the review! I updated the commit message in v2 explaining better why resets occur without user interaction, how the issue was reproducible using ethtool, and added some better wording.
Quoted 5 lines
Quoted 4 lines
Signed-off-by Benjamin Mikailenko <[email protected]>--- drivers/net/ethernet/intel/ice/ice_lib.c | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
Quoted 7 lines
[...]
Quoted 2 lines
Signature · 1 line
2.34.3Thanks,
Olek
Thank you,
Ben
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan