Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH iwl-net] ice: Reset stats on queues num change
@ 2023-07-14 11:47 Przemek Kitszel
  2023-07-19 14:04 ` Simon Horman
  2023-07-19 15:25 ` Alexander Lobakin
  0 siblings, 2 replies; 3+ messages in thread
From: Przemek Kitszel @ 2023-07-14 11:47 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: Benjamin Mikailenko, netdev, Tony Nguyen, Przemek Kitszel

Reset VSI stats on queues number change.

Commit 288ecf491b16 ("ice: Accumulate ring statistics over reset")
implemented functionality for interface statistics to persist over reset,
but it left stats persisting over queue count reconfiguration.

Following scenario is fixed here:
 # Observe statistics for Tx/Rx queues
ethtool -S ethX
 # change number of queues
ethtool -L ethX combined 10
 # Observe statistics for Tx/Rx queues (after reset)
ethtool -S ethX

Ben has left a note where to place the VSI stats reset,
what made this fix much easier to do.

Note that newly allocated structs (case of num_txq > prev_txq) don't
need zeroing.

Fixes: 288ecf491b16 ("ice: Accumulate ring statistics over reset")
Suggested-by: Benjamin Mikailenko <benjamin.mikailenko@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 33 ++++++++++++++++++++----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 00e3afd507a4..09942bdea25d 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -3130,13 +3130,15 @@ ice_vsi_rebuild_set_coalesce(struct ice_vsi *vsi,
 }
 
 /**
- * ice_vsi_realloc_stat_arrays - Frees unused stat structures
+ * ice_vsi_adjust_stat_arrays - Adjust VSI stat structures
  * @vsi: VSI pointer
  * @prev_txq: Number of Tx rings before ring reallocation
  * @prev_rxq: Number of Rx rings before ring reallocation
+ *
+ * Zero stat structures before reuse, free redundant ones.
  */
 static void
-ice_vsi_realloc_stat_arrays(struct ice_vsi *vsi, int prev_txq, int prev_rxq)
+ice_vsi_adjust_stat_arrays(struct ice_vsi *vsi, int prev_txq, int prev_rxq)
 {
 	struct ice_vsi_stats *vsi_stat;
 	struct ice_pf *pf = vsi->back;
@@ -3149,7 +3151,17 @@ ice_vsi_realloc_stat_arrays(struct ice_vsi *vsi, int prev_txq, int prev_rxq)
 
 	vsi_stat = pf->vsi_stats[vsi->idx];
 
-	if (vsi->num_txq < prev_txq) {
+	if (vsi->num_txq != prev_txq) {
+		/* first, reset structs that we will reuse */
+		int reuse_q_cnt = min_t(int, vsi->num_txq, prev_txq);
+
+		for (i = 0; i < reuse_q_cnt; i++) {
+			struct ice_ring_stats *rs = vsi_stat->tx_ring_stats[i];
+
+			if (rs)
+				memset(rs, 0, sizeof(*rs));
+		}
+		/* second, free redundant ones */
 		for (i = vsi->num_txq; i < prev_txq; i++) {
 			if (vsi_stat->tx_ring_stats[i]) {
 				kfree_rcu(vsi_stat->tx_ring_stats[i], rcu);
@@ -3158,7 +3170,16 @@ ice_vsi_realloc_stat_arrays(struct ice_vsi *vsi, int prev_txq, int prev_rxq)
 		}
 	}
 
-	if (vsi->num_rxq < prev_rxq) {
+	/* apply very same logic as for tx */
+	if (vsi->num_rxq != prev_rxq) {
+		int reuse_q_cnt = min_t(int, vsi->num_rxq, prev_rxq);
+
+		for (i = 0; i < reuse_q_cnt; i++) {
+			struct ice_ring_stats *rs = vsi_stat->rx_ring_stats[i];
+
+			if (rs)
+				memset(rs, 0, sizeof(*rs));
+		}
 		for (i = vsi->num_rxq; i < prev_rxq; i++) {
 			if (vsi_stat->rx_ring_stats[i]) {
 				kfree_rcu(vsi_stat->rx_ring_stats[i], rcu);
@@ -3222,7 +3243,9 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags)
 		return ice_schedule_reset(pf, ICE_RESET_PFR);
 	}
 
-	ice_vsi_realloc_stat_arrays(vsi, prev_txq, prev_rxq);
+	ice_vsi_adjust_stat_arrays(vsi, prev_txq, prev_rxq);
+	if (vsi->num_txq != prev_txq || vsi->num_rxq != prev_rxq)
+		vsi->stat_offsets_loaded = false;
 
 	ice_vsi_rebuild_set_coalesce(vsi, coalesce, prev_num_q_vectors);
 	kfree(coalesce);

base-commit: 9d23aac8a85f69239e585c8656c6fdb21be65695
-- 
2.40.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-19 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-14 11:47 [Intel-wired-lan] [PATCH iwl-net] ice: Reset stats on queues num change Przemek Kitszel
2023-07-19 14:04 ` Simon Horman
2023-07-19 15:25 ` Alexander Lobakin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox