intel-wired-lan.lists.osuosl.org archive mirror
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH net v1] ice: Reset stats on queue change
@ 2022-12-20 16:05 Benjamin Mikailenko
  2022-12-20 17:08 ` Alexander Lobakin
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Mikailenko @ 2022-12-20 16:05 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: Benjamin Mikailenko

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.

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

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 703f73e54561..ce791d90800d 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -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);
 
-- 
2.34.3

_______________________________________________
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

* Re: [Intel-wired-lan] [PATCH net v1] ice: Reset stats on queue change
  2022-12-20 16:05 [Intel-wired-lan] [PATCH net v1] ice: Reset stats on queue change Benjamin Mikailenko
@ 2022-12-20 17:08 ` Alexander Lobakin
  2022-12-20 18:59   ` Benjamin Mikailenko
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Lobakin @ 2022-12-20 17:08 UTC (permalink / raw)
  To: Benjamin Mikailenko; +Cc: intel-wired-lan

From: Benjamin Mikailenko <benjamin.mikailenko@intel.com>
Date: Tue, 20 Dec 2022 11:05:06 -0500

> 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).

> 
> 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.

> Signed-off-by: Benjamin Mikailenko <benjamin.mikailenko@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_lib.c | 65 ++++++++++++++++++++++++
>  1 file changed, 65 insertions(+)

[...]

> -- 
> 2.34.3

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

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

* Re: [Intel-wired-lan] [PATCH net v1] ice: Reset stats on queue change
  2022-12-20 17:08 ` Alexander Lobakin
@ 2022-12-20 18:59   ` Benjamin Mikailenko
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Mikailenko @ 2022-12-20 18:59 UTC (permalink / raw)
  To: Alexander Lobakin; +Cc: intel-wired-lan



On 12/20/2022 9:08 AM, Alexander Lobakin wrote:
> From: Benjamin Mikailenko <benjamin.mikailenko@intel.com>
> Date: Tue, 20 Dec 2022 11:05:06 -0500
> 
>> 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).
> 
>>
>> 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.

>> Signed-off-by: Benjamin Mikailenko <benjamin.mikailenko@intel.com>
>> ---
>>  drivers/net/ethernet/intel/ice/ice_lib.c | 65 ++++++++++++++++++++++++
>>  1 file changed, 65 insertions(+)
> 
> [...]
> 
>> -- 
>> 2.34.3
> 
> Thanks,
> Olek

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

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

end of thread, other threads:[~2022-12-20 18:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-20 16:05 [Intel-wired-lan] [PATCH net v1] ice: Reset stats on queue change Benjamin Mikailenko
2022-12-20 17:08 ` Alexander Lobakin
2022-12-20 18:59   ` Benjamin Mikailenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).