Re: [Intel-wired-lan] [PATCH iwl-next v4 2/6] ice: pass pointer to ice_fetch_u64_stats_per_ring

2025-12-18 Thread Rinitha, SX
> -Original Message-
> From: Intel-wired-lan  On Behalf Of Jacob 
> Keller
> Sent: 21 November 2025 01:51
> To: Loktionov, Aleksandr ; Lobakin, Aleksander 
> ; Nguyen, Anthony L 
> ; Kitszel, Przemyslaw 
> 
> Cc: Simon Horman ; [email protected]; 
> [email protected]; Keller, Jacob E ; 
> Loktionov, Aleksandr 
> Subject: [Intel-wired-lan] [PATCH iwl-next v4 2/6] ice: pass pointer to 
> ice_fetch_u64_stats_per_ring
>
> The ice_fetch_u64_stats_per_ring function takes a pointer to the syncp from 
> the ring stats to synchronize reading of the packet stats. It also takes a
*copy* of the ice_q_stats fields instead of a pointer to the stats. This 
completely defeats the point of using the u64_stats API. We pass the stats by 
value, so they are static at the point of reading within the 
u64_stats_fetch_retry loop.
>
> Simplify the function to take a pointer to the ice_ring_stats instead of two 
> separate parameters. Additionally, since we never call this outside of 
> ice_main.c, make it a static function.
>
> Reviewed-by: Aleksandr Loktionov 
> Signed-off-by: Jacob Keller 
> ---
> drivers/net/ethernet/intel/ice/ice.h  |  3 ---
> drivers/net/ethernet/intel/ice/ice_main.c | 24 +---
> 2 files changed, 9 insertions(+), 18 deletions(-)
>

Tested-by: Rinitha S  (A Contingent worker at Intel)


Re: [Intel-wired-lan] [PATCH iwl-next v4 2/6] ice: pass pointer to ice_fetch_u64_stats_per_ring

2025-12-03 Thread Jacob Keller


On 11/25/2025 2:16 AM, Simon Horman wrote:
> On Thu, Nov 20, 2025 at 12:20:42PM -0800, Jacob Keller wrote:
>> The ice_fetch_u64_stats_per_ring function takes a pointer to the syncp from
>> the ring stats to synchronize reading of the packet stats. It also takes a
>> *copy* of the ice_q_stats fields instead of a pointer to the stats. This
>> completely defeats the point of using the u64_stats API. We pass the stats
>> by value, so they are static at the point of reading within the
>> u64_stats_fetch_retry loop.
>>
>> Simplify the function to take a pointer to the ice_ring_stats instead of
>> two separate parameters. Additionally, since we never call this outside of
>> ice_main.c, make it a static function.
>>
>> Reviewed-by: Aleksandr Loktionov 
>> Signed-off-by: Jacob Keller 
> 
> The *copy* was certainly working against us here.
> But TBH, C syntax led me to read the code more than
> once before seeing it.
> 

Yes, I had the exact same issue. It took me a while while refactoring to
notice this particular bug...

> Reviewed-by: Simon Horman 



OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: [Intel-wired-lan] [PATCH iwl-next v4 2/6] ice: pass pointer to ice_fetch_u64_stats_per_ring

2025-11-25 Thread Simon Horman
On Thu, Nov 20, 2025 at 12:20:42PM -0800, Jacob Keller wrote:
> The ice_fetch_u64_stats_per_ring function takes a pointer to the syncp from
> the ring stats to synchronize reading of the packet stats. It also takes a
> *copy* of the ice_q_stats fields instead of a pointer to the stats. This
> completely defeats the point of using the u64_stats API. We pass the stats
> by value, so they are static at the point of reading within the
> u64_stats_fetch_retry loop.
> 
> Simplify the function to take a pointer to the ice_ring_stats instead of
> two separate parameters. Additionally, since we never call this outside of
> ice_main.c, make it a static function.
> 
> Reviewed-by: Aleksandr Loktionov 
> Signed-off-by: Jacob Keller 

The *copy* was certainly working against us here.
But TBH, C syntax led me to read the code more than
once before seeing it.

Reviewed-by: Simon Horman 


[Intel-wired-lan] [PATCH iwl-next v4 2/6] ice: pass pointer to ice_fetch_u64_stats_per_ring

2025-11-20 Thread Jacob Keller
The ice_fetch_u64_stats_per_ring function takes a pointer to the syncp from
the ring stats to synchronize reading of the packet stats. It also takes a
*copy* of the ice_q_stats fields instead of a pointer to the stats. This
completely defeats the point of using the u64_stats API. We pass the stats
by value, so they are static at the point of reading within the
u64_stats_fetch_retry loop.

Simplify the function to take a pointer to the ice_ring_stats instead of
two separate parameters. Additionally, since we never call this outside of
ice_main.c, make it a static function.

Reviewed-by: Aleksandr Loktionov 
Signed-off-by: Jacob Keller 
---
 drivers/net/ethernet/intel/ice/ice.h  |  3 ---
 drivers/net/ethernet/intel/ice/ice_main.c | 24 +---
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice.h 
b/drivers/net/ethernet/intel/ice/ice.h
index 147aaee192a7..5c01e886e83e 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -957,9 +957,6 @@ u16 ice_get_avail_rxq_count(struct ice_pf *pf);
 int ice_vsi_recfg_qs(struct ice_vsi *vsi, int new_rx, int new_tx, bool locked);
 void ice_update_vsi_stats(struct ice_vsi *vsi);
 void ice_update_pf_stats(struct ice_pf *pf);
-void
-ice_fetch_u64_stats_per_ring(struct u64_stats_sync *syncp,
-struct ice_q_stats stats, u64 *pkts, u64 *bytes);
 int ice_up(struct ice_vsi *vsi);
 int ice_down(struct ice_vsi *vsi);
 int ice_down_up(struct ice_vsi *vsi);
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index 0b6175ade40d..4133d297dda2 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -6811,25 +6811,23 @@ int ice_up(struct ice_vsi *vsi)
 
 /**
  * ice_fetch_u64_stats_per_ring - get packets and bytes stats per ring
- * @syncp: pointer to u64_stats_sync
- * @stats: stats that pkts and bytes count will be taken from
+ * @stats: pointer to ring stats structure
  * @pkts: packets stats counter
  * @bytes: bytes stats counter
  *
  * This function fetches stats from the ring considering the atomic operations
  * that needs to be performed to read u64 values in 32 bit machine.
  */
-void
-ice_fetch_u64_stats_per_ring(struct u64_stats_sync *syncp,
-struct ice_q_stats stats, u64 *pkts, u64 *bytes)
+static void ice_fetch_u64_stats_per_ring(struct ice_ring_stats *stats,
+u64 *pkts, u64 *bytes)
 {
unsigned int start;
 
do {
-   start = u64_stats_fetch_begin(syncp);
-   *pkts = stats.pkts;
-   *bytes = stats.bytes;
-   } while (u64_stats_fetch_retry(syncp, start));
+   start = u64_stats_fetch_begin(&stats->syncp);
+   *pkts = stats->stats.pkts;
+   *bytes = stats->stats.bytes;
+   } while (u64_stats_fetch_retry(&stats->syncp, start));
 }
 
 /**
@@ -6853,9 +6851,7 @@ ice_update_vsi_tx_ring_stats(struct ice_vsi *vsi,
ring = READ_ONCE(rings[i]);
if (!ring || !ring->ring_stats)
continue;
-   ice_fetch_u64_stats_per_ring(&ring->ring_stats->syncp,
-ring->ring_stats->stats, &pkts,
-&bytes);
+   ice_fetch_u64_stats_per_ring(ring->ring_stats, &pkts, &bytes);
vsi_stats->tx_packets += pkts;
vsi_stats->tx_bytes += bytes;
vsi->tx_restart += ring->ring_stats->tx_stats.restart_q;
@@ -6899,9 +6895,7 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi)
struct ice_ring_stats *ring_stats;
 
ring_stats = ring->ring_stats;
-   ice_fetch_u64_stats_per_ring(&ring_stats->syncp,
-ring_stats->stats, &pkts,
-&bytes);
+   ice_fetch_u64_stats_per_ring(ring_stats, &pkts, &bytes);
vsi_stats->rx_packets += pkts;
vsi_stats->rx_bytes += bytes;
vsi->rx_buf_failed += ring_stats->rx_stats.alloc_buf_failed;

-- 
2.51.0.rc1.197.g6d975e95c9d7