ice: properly use u64_stats API for all ring stats
Subsystems (3)
v2 cover ice: properly use u64_stats API for all ring stats
The ice driver has multiple u64 values stored in the ring structures for each queue used for statistics. These are accumulated in ice_update_vsi_stats(). The packet and byte values are read using the u64_stats API from <linux/u64_stats_sync.h>.
Several non-standard counters are also accumulated in the same function, but do not use the u64_stats API. This could result in load/store tears on 32-bit architectures. Further, since commit 316580b69d0a ("u64_stats:
provide u64_stats_t type"), the u64 stats API has had u64_stats_t and access functions which convert to local64_t on 64-bit architectures.
The ice driver doesn't use u64_stats_t and these access functions. Thus even on 64-bit architectures it could read inconsistent values. This series refactors the ice driver to use the updated API. Along the way I noticed several other issues and inconsistencies which I have cleaned up, summarized below.
*) The driver never called u64_stats_init, leaving the syncp improperly
initialized. Since the field is part of a kzalloc block, this only impacts 32-bit systems with CONFIG_LOCKDEP enabled.
*) A few locations accessed the packets and byte counts directly without
using the u64 stats API.
*) The prev_pkt integer field is moved out of the stats structure and into
the ice_tx_ring structure directly.
*) Cache line comments in ice_tx_ring and ice_rx_ring were out of date and
did not match the actual intended layout for systems with 64-bit cache lines. Convert the structures to use __cacheline_group instead of comments.
*) The ice_fetch_u64_stats_per_ring() function took the ice_q_stats by
value, defeating the point of using the u64_stats API entirely.
To keep the stats increments short, I introduced ice_stats_inc, as otherwise each stat increment has to be quite verbose. Similarly a few places read only one stat, so I added ice_stats_read for those.
This version uses struct ice_vsi_(tx|rx)_stats structures defined in ice_main.c for the accumulator. I haven't come up with a better solution that allows accumulating nicely without this structure. Its a bit frustrating as it copies the entries in the ring stats structures but with u64 instead of u64_stats_t.
I am also still not entirely certain how the ice_update_vsi_ring_stats() function is synchronized in the ice driver. It is called from multiple places without an obvious synchronization mechanism. It is ultimately called from the service task and from ethtool, and I think it may also be called from one of the netdev stats callbacks.
I'm open to suggestions on ways to improve this, as I think the result still has some ugly logic and a fair amount of near duplicate code.
I have included the cacheline cleanup in ice_tx_ring and ice_rx_ring here, but that could arguably be split to its own series. I only noticed it because of attempting to move the prev_pkt field out of the ring stats. I replaced the comments with cacheline_group, but I did not make an attempt to optimize the existing cachelines. Probably we should experiment with the method used in idpf with the 'read-mostly', 'read-write' and 'cold' groupings, but doing so will require a more thorough deep dive on performance profiling and tuning.
---
Changes in v2:
- Fix minor typos.
- Link to v1: https://patch.msgid.link/[email protected]
---
Jacob Keller (9):
ice: initialize ring_stats->syncp
ice: use cacheline groups for ice_rx_ring structure
ice: use cacheline groups for ice_tx_ring structure
ice: move prev_pkt from ice_txq_stats to ice_tx_ring
ice: pass pointer to ice_fetch_u64_stats_per_ring
ice: remove ice_q_stats struct and use struct_group
ice: use u64_stats API to access pkts/bytes in dim sample
ice: shorten ring stat names and add accessors
ice: convert all ring stats to u64_stats_t
drivers/net/ethernet/intel/ice/ice.h | 3 - drivers/net/ethernet/intel/ice/ice_lib.h | 6 + drivers/net/ethernet/intel/ice/ice_txrx.h | 135 ++++++++++++----- drivers/net/ethernet/intel/ice/ice_txrx_lib.h | 2 +- drivers/net/ethernet/intel/ice/ice_base.c | 4 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 30 ++-- drivers/net/ethernet/intel/ice/ice_lib.c | 61 ++++++-- drivers/net/ethernet/intel/ice/ice_main.c | 201 +++++++++++++++++--------- drivers/net/ethernet/intel/ice/ice_txrx.c | 45 +++--- drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 2 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +- 11 files changed, 331 insertions(+), 162 deletions(-)
---
base-commit: c5acd2847bb5371988d6b5c165b0776967cc7da2
change-id: 20251016-jk-refactor-queue-stats-9e721b34ce01
Best regards,
Signature · 1 line
Jacob Keller <[email protected]>
PATCH v2 1/9 ice: initialize ring_stats->syncp
The u64_stats_sync structure is empty on 64-bit systems. However, on 32-bit systems it contains a seqcount_t which needs to be initialized. While the memory is zero-initialized, a lack of u64_stats_init means that lockdep won't get initialized properly. Fix this by adding u64_stats_init() calls to the rings just after allocation.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/intel/ice/ice_lib.c +5 -0
@@ -400,7 +400,10 @@ static int ice_vsi_alloc_ring_stats(struct ice_vsi *vsi)if (!ring_stats) goto err_out; +u64_stats_init (&ring_stats->syncp); +WRITE_ONCE (tx_ring_stats[i], ring_stats); + } ring->ring_stats = ring_stats;
@@ -419,6 +422,8 @@ static int ice_vsi_alloc_ring_stats(struct ice_vsi *vsi)if (!ring_stats) goto err_out; +u64_stats_init (&ring_stats->syncp); +WRITE_ONCE (rx_ring_stats[i], ring_stats); }
Signature · 1 line
2.51.0.rc1.197.g6d975e95c9d7
PATCH v2 2/9 ice: use cacheline groups for ice_rx_ring structure
In reply to Jacob KellerThe ice ring structure was reorganized back by commit 65124bbf980c ("ice:
Reorganize tx_buf and ring structs"), and later split into a separate ice_rx_ring structure by commit e72bba21355d ("ice: split ice_ring onto Tx/Rx separate structs")
The ice_rx_ring structure has comments left over from this prior reorganization indicating which fields belong to which cachelines. Unfortunately, these comments are not all accurate. The intended layout is for x86_64 systems with a 64-byte cache.
* Cacheline 1 spans from the start of the struct to the end of the rx_fqes and xdp_buf union. The comments correctly match this.
* Cacheline 2 spans from hdr_fqes to the end of hdr_truesize, but the comment indicates it should end xdp and xsk union.
* Cacheline 3 spans from the truesize field to the xsk_pool, but the comment wants this to be from the pkt_ctx down to the rcu head field.
* Cacheline 4 spans from the rx_hdr_len down to the flags field, but the comment indicates that it starts back at the ice_channel structure pointer.
* Cacheline 5 is indicated to cover the xdp_rxq. Because this field is aligned to 64 bytes, this is actually true. However, there is a large 45 byte gap at the end of cacheline 4.
The use of comments to indicate cachelines is poor design. In practice, comments like this quickly become outdated as developers add or remove fields, or as other sub-structures change layout and size unexpectedly.
The ice_rx_ring structure *is* 5 cachelines (320 bytes), but ends up having quite a lot of empty space at the end just before xdp_rxq.
Replace the comments with __cacheline_group_(begin|end)_aligned() annotations. These macros enforce alignment to the start of cachelines, and enforce padding between groups, thus guaranteeing that a following group cannot be part of the same cacheline.
Doing this changes the layout by effectively spreading the padding at the tail of cacheline 4 between groups to ensure that the relevant fields are kept as separate cachelines on x86_64 systems. For systems with the expected cache line size of 64 bytes, the structure size does not change. For systems with a larger SMB_CACHE_BYTES size, the structure *will* increase in size a fair bit, however we'll now guarantee that each group is in a separate cacheline. This has an advantage that updates to fields in one group won't trigger cacheline eviction of the other groups. This comes at the expense of extra memory footprint for the rings.
If fields get re-arranged, added, or removed, the alignment and padding ensure the relevant fields are kept on separate cache lines. This could result in unexpected changes in the structure size due to padding to keep cachelines separate.
To catch such changes during early development, add build time compiler assertions that check the size of each group to ensure it doesn't exceed 64 bytes, the expected cache line size. The assertion checks that the size of the group excluding any padding at the end is less than the provided size of 64 bytes. This type of check will behave the same even on architectures with larger cache sizes. The primary aim is to produce a warning if developers add fields into a cacheline group which exceeds the size of the expected 64 byte groupings.
--- drivers/net/ethernet/intel/ice/ice_txrx.h | 26 +++++++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.h +21 -5
@@ -236,7 +236,7 @@ struct ice_tstamp_ring { }____cacheline_internodealigned_in_smp ;struct ice_rx_ring { -/* CL1 - 1st cacheline starts here */ +__cacheline_group_begin_aligned (cl1);void *desc;/* Descriptor ring memory */ struct page_pool *pp;struct net_device *netdev;/* netdev ring maps to */
@@ -253,8 +253,9 @@ struct ice_rx_ring {struct libeth_fqe *rx_fqes;struct xdp_buff **xdp_buf; }; +__cacheline_group_end_aligned (cl1); -/* CL2 - 2nd cacheline starts here */ +__cacheline_group_begin_aligned (cl2);struct libeth_fqe *hdr_fqes;struct page_pool *hdr_pp;
@@ -262,8 +263,9 @@ struct ice_rx_ring {struct libeth_xdp_buff_stash xdp;struct libeth_xdp_buff *xsk; }; +__cacheline_group_end_aligned (cl2); -/* CL3 - 3rd cacheline starts here */ +__cacheline_group_begin_aligned (cl3); union { struct ice_pkt_ctx pkt_ctx; struct {
@@ -284,7 +286,9 @@ struct ice_rx_ring {struct ice_ring_stats *ring_stats;struct rcu_head rcu;/* to avoid race on free */ -/* CL4 - 4th cacheline starts here */ +__cacheline_group_end_aligned (cl3); + +__cacheline_group_begin_aligned (cl4);struct ice_channel *ch;struct ice_tx_ring *xdp_ring;struct ice_rx_ring *next;/* pointer to next ring in q_vector */
@@ -298,10 +302,22 @@ struct ice_rx_ring {#define ICE_RX_FLAGS_MULTIDEV BIT(3)#define ICE_RX_FLAGS_RING_GCS BIT(4)u8 flags; -/* CL5 - 5th cacheline starts here */ +__cacheline_group_end_aligned (cl4); + +__cacheline_group_begin_aligned (cl5);struct xdp_rxq_info xdp_rxq; +__cacheline_group_end_aligned (cl5); }____cacheline_internodealigned_in_smp ; +static inline void ice_rx_ring_struct_check (void ) +{ + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl1, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl2, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl3, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl4, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl5, 64); +} +struct ice_tx_ring {/* CL1 - 1st cacheline starts here */ struct ice_tx_ring *next;/* pointer to next ring in q_vector */
drivers/net/ethernet/intel/ice/ice_main.c +2 -0
@@ -5916,6 +5916,8 @@ static int __init ice_module_init(void) {int status = -ENOMEM ; +ice_rx_ring_struct_check (); +pr_info ("%s\n" , ice_driver_string);pr_info ("%s\n" , ice_copyright);
Signature · 1 line
2.51.0.rc1.197.g6d975e95c9d7
RE: [PATCH iwl-next v2 2/9] ice: use cacheline groups for ice_rx_ring structure
Quoted 91 lines
-----Original Message-----
From: Keller, Jacob E <[email protected]>
Sent: Wednesday, November 5, 2025 10:07 PM
To: Loktionov, Aleksandr <[email protected]>; Lobakin, Aleksander <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; Keller, Jacob E <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [PATCH iwl-next v2 2/9] ice: use cacheline groups forice_rx_ringstructureThe ice ring structure was reorganized back by commit
65124bbf980c("ice:
Reorganizetx_bufand ring structs"), and later split into a separateice_rx_ringstructure by commite72bba21355d("ice: splitice_ringonto Tx/Rx separate structs")The
ice_rx_ringstructure has comments left over from this prior reorganization indicating which fields belong to which cachelines. Unfortunately, these comments are not all accurate. The intended layout is forx86_64systems with a 64-byte cache.* Cacheline 1 spans from the start of the struct to the end of the
rx_fqes
andxdp_bufunion. The comments correctly match this.* Cacheline 2 spans from
hdr_fqesto the end ofhdr_truesize, but the comment indicates it should end xdp and xsk union.* Cacheline 3 spans from the truesize field to the
xsk_pool, but the comment wants this to be from thepkt_ctxdown to the rcu head
field.* Cacheline 4 spans from the
rx_hdr_lendown to the flags field, but
the
comment indicates that it starts back at theice_channelstructure pointer.* Cacheline 5 is indicated to cover the
xdp_rxq. Because this field
is
aligned to 64 bytes, this is actually true. However, there is a
large 45
byte gap at the end of cacheline 4.The use of comments to indicate cachelines is poor design. In practice, comments like this quickly become outdated as developers add or remove fields, or as other sub-structures change layout and size unexpectedly.
The
ice_rx_ringstructure *is* 5 cachelines (320 bytes), but ends up having quite a lot of empty space at the end just beforexdp_rxq.Replace the comments with __cacheline_group_(begin|end)_aligned() annotations. These macros enforce alignment to the start of cachelines, and enforce padding between groups, thus guaranteeing that a following group cannot be part of the same cacheline.
Doing this changes the layout by effectively spreading the padding at the tail of cacheline 4 between groups to ensure that the relevant fields are kept as separate cachelines on
x86_64systems. For systems with the expected cache line size of 64 bytes, the structure size does not change.
For systems with a largerSMB_CACHE_BYTESsize, the structure *will* increase in size a fair bit, however we'll now guarantee that each group is in a separate cacheline. This has an advantage that updates to fields in one group won't trigger cacheline eviction of the other groups. This comes at the expense of extra memory footprint for the rings.If fields get re-arranged, added, or removed, the alignment and padding ensure the relevant fields are kept on separate cache lines. This could result in unexpected changes in the structure size due to padding to keep cachelines separate.
To catch such changes during early development, add build time compiler assertions that check the size of each group to ensure it doesn't exceed 64 bytes, the expected cache line size. The assertion checks that the size of the group excluding any padding at the end is less than the provided size of 64 bytes. This type of check will behave the same even on architectures with larger cache sizes. The primary aim is to produce a warning if developers add fields into a cacheline group which exceeds the size of the expected 64 byte groupings.
Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Jacob Keller <[email protected]>---
...
Quoted 2 lines
--
2.51.0.rc1.197.g6d975e95c9d7
Simon Horman
reviewerRe: [PATCH iwl-next v2 2/9] ice: use cacheline groups for ice_rx_ring structure
In reply to Jacob KellerQuoted 71 lines · Jacob Keller
The ice ring structure was reorganized back by commit
65124bbf980c("ice:
Reorganizetx_bufand ring structs"), and later split into a separateice_rx_ringstructure by commite72bba21355d("ice: splitice_ringonto Tx/Rx separate structs")The
ice_rx_ringstructure has comments left over from this prior reorganization indicating which fields belong to which cachelines. Unfortunately, these comments are not all accurate. The intended layout is forx86_64systems with a 64-byte cache.* Cacheline 1 spans from the start of the struct to the end of the
rx_fqesandxdp_bufunion. The comments correctly match this.* Cacheline 2 spans from
hdr_fqesto the end ofhdr_truesize, but the comment indicates it should end xdp and xsk union.* Cacheline 3 spans from the truesize field to the
xsk_pool, but the comment wants this to be from thepkt_ctxdown to the rcu head field.* Cacheline 4 spans from the
rx_hdr_lendown to the flags field, but the comment indicates that it starts back at theice_channelstructure pointer.* Cacheline 5 is indicated to cover the
xdp_rxq. Because this field is aligned to 64 bytes, this is actually true. However, there is a large 45 byte gap at the end of cacheline 4.The use of comments to indicate cachelines is poor design. In practice, comments like this quickly become outdated as developers add or remove fields, or as other sub-structures change layout and size unexpectedly.
The
ice_rx_ringstructure *is* 5 cachelines (320 bytes), but ends up having quite a lot of empty space at the end just beforexdp_rxq.Replace the comments with __cacheline_group_(begin|end)_aligned() annotations. These macros enforce alignment to the start of cachelines, and enforce padding between groups, thus guaranteeing that a following group cannot be part of the same cacheline.
Doing this changes the layout by effectively spreading the padding at the tail of cacheline 4 between groups to ensure that the relevant fields are kept as separate cachelines on
x86_64systems. For systems with the expected cache line size of 64 bytes, the structure size does not change. For systems with a largerSMB_CACHE_BYTESsize, the structure *will* increase in size a fair bit, however we'll now guarantee that each group is in a separate cacheline. This has an advantage that updates to fields in one group won't trigger cacheline eviction of the other groups. This comes at the expense of extra memory footprint for the rings.If fields get re-arranged, added, or removed, the alignment and padding ensure the relevant fields are kept on separate cache lines. This could result in unexpected changes in the structure size due to padding to keep cachelines separate.
To catch such changes during early development, add build time compiler assertions that check the size of each group to ensure it doesn't exceed 64 bytes, the expected cache line size. The assertion checks that the size of the group excluding any padding at the end is less than the provided size of 64 bytes. This type of check will behave the same even on architectures with larger cache sizes. The primary aim is to produce a warning if developers add fields into a cacheline group which exceeds the size of the expected 64 byte groupings.
Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_txrx.h | 26 +++++++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-)drivers/net/ethernet/intel/ice/ice_txrx.h +0
-0
...
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_txrx.h +3
-1@@ -298,10 +302,22 @@ struct ice_rx_ring {#define ICE_RX_FLAGS_MULTIDEV BIT(3)#define ICE_RX_FLAGS_RING_GCS BIT(4)u8 flags; -/* CL5 - 5th cacheline starts here */ +__cacheline_group_end_aligned (cl4); + +__cacheline_group_begin_aligned (cl5);struct xdp_rxq_info xdp_rxq;
drivers/net/ethernet/intel/ice/ice_txrx.h struct ice_rx_ring { · line 318
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_txrx.h +8
-0+__cacheline_group_end_aligned (cl5); }____cacheline_internodealigned_in_smp ; +static inline void ice_rx_ring_struct_check (void ) +{ + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl1, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl2, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl3, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl4, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl5, 64);
Hi Jacob,
Unfortunately the last line results in a build failure on ARM (32-bit) with allmodconfig. It seems that in that case the size of the group is 128 bytes.
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_txrx.h +2
-0+} +struct ice_tx_ring {/* CL1 - 1st cacheline starts here */ struct ice_tx_ring *next;/* pointer to next ring in q_vector */
...
Re: [PATCH iwl-next v2 2/9] ice: use cacheline groups for ice_rx_ring structure
Quoted 23 lines · Simon Horman
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_txrx.h +3
-1@@ -298,10 +302,22 @@ struct ice_rx_ring {#define ICE_RX_FLAGS_MULTIDEV BIT(3)#define ICE_RX_FLAGS_RING_GCS BIT(4)u8 flags; -/* CL5 - 5th cacheline starts here */ +__cacheline_group_end_aligned (cl4); + +__cacheline_group_begin_aligned (cl5);struct xdp_rxq_info xdp_rxq;drivers/net/ethernet/intel/ice/ice_txrx.h struct ice_rx_ring { · line 318
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_txrx.h +8
-0+__cacheline_group_end_aligned (cl5); }____cacheline_internodealigned_in_smp ; +static inline void ice_rx_ring_struct_check (void ) +{ + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl1, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl2, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl3, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl4, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl5, 64);Hi Jacob,
Quoted 4 lines
Unfortunately the last line results in a build failure on ARM (32-bit) with allmodconfig. It seems that in that case the size of the group is 128 bytes.
Hm. That's interesting. My understanding is that CACHELINE_ASSERT_GROUP_SIZE calculates the size without taking into account the padding after the last element added by the cacheline_group_end_aligned. Perhaps there's something in one of the groups that gets larger due to also being cacheline_aligned and ARM system having 128-byte cacheline instead of 64, and thats what results in the larger increase in size.
Is there an easy way to cross compile for ARM so I can check the struct layout myself?
The easy fix option would be to only enable these assertions on the x86 platform they were designed for specifically.. But thats kind of ugly and I don't like it...
Quoted 7 lines
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_txrx.h +2
-0+} +struct ice_tx_ring {/* CL1 - 1st cacheline starts here */ struct ice_tx_ring *next;/* pointer to next ring in q_vector */ ...
Re: [PATCH iwl-next v2 2/9] ice: use cacheline groups for ice_rx_ring structure
In reply to Simon HormanQuoted 23 lines · Simon Horman
Quoted 9 lines · Jacob Keller
drivers/net/ethernet/intel/ice/ice_txrx.h +3
-1@@ -298,10 +302,22 @@ struct ice_rx_ring {#define ICE_RX_FLAGS_MULTIDEV BIT(3)#define ICE_RX_FLAGS_RING_GCS BIT(4)u8 flags; -/* CL5 - 5th cacheline starts here */ +__cacheline_group_end_aligned (cl4); + +__cacheline_group_begin_aligned (cl5);struct xdp_rxq_info xdp_rxq;drivers/net/ethernet/intel/ice/ice_txrx.h struct ice_rx_ring { · line 318
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_txrx.h +8
-0+__cacheline_group_end_aligned (cl5); }____cacheline_internodealigned_in_smp ; +static inline void ice_rx_ring_struct_check (void ) +{ + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl1, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl2, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl3, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl4, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_rx_ring, cl5, 64);Hi Jacob,
Quoted 4 lines
Unfortunately the last line results in a build failure on ARM (32-bit) with allmodconfig. It seems that in that case the size of the group is 128 bytes.
Ok. I got a cross compilation working which actually built with 128-byte cache size. Here's the relevant part of the structure layout:
Quoted 6 lines
/* --- cacheline 8 boundary (512 bytes) --- */
struct {
} __cacheline_group_pad__cl4 __attribute__((__aligned__(128))); /* 512 0 */
__u8 __cacheline_group_begin__cl5[0] __attribute__((__aligned__(128))); /* 512 0 */
struct xdp_rxq_info xdp_rxq __attribute__((__aligned__(128))); /* 512 128 */The xdp_rxq_info structure is aligned to 128 bytes, due to the ____cacheline_aligned attribute.
Quoted 4 lines
/* XXX last struct has 104 bytes of padding */
/* --- cacheline 10 boundary (640 bytes) --- */
__u8 __cacheline_group_end__cl5[0] __attribute__((__aligned__(4))); /* 640 0 */Due to the padding, this results in the group end being placed after the 104 bytes of padding. This is because the member struct has the padding, rather than the ice_rx_ring structure.
Quoted 8 lines
struct {
} __cacheline_group_pad__cl5 __attribute__((__aligned__(128))); /* 640 0 */
/* size: 640, cachelines: 10, members: 48 */
/* sum members: 263, holes: 6, sum holes: 377 */
/* paddings: 1, sum paddings: 104 */
/* forced alignments: 18, forced holes: 5, sum forced holes: 373 */
} __attribute__((__aligned__(128)));I'm not sure what the most ideal solution here is. I think the simplest is to use SMP_CACHE_BYTES for the last cacheline size assertion, since this one will always scale to the size of the cacheline due to the __cacheline_aligned attribute.
Does that seem reasonable? I guess I could make them all SMP_CATCH_BYTES.. but I feel like that makes them a bit less clear. The other groups don't have such varying sizes as the CACHELINE_ASSERT_GROUP_SIZE doesn't include the padding added by the cacheline_group_end, and using SMP_CACHE_BYTES would mean new members could pass on 128-byte cache size systems even if we exceeded the intended limit of 64bytes. Then again, on 128-byte cache size systems the structure does grow to 640 bytes due to the padding which is keeping the cache groups on dedicated cache lines.. We could drop the assertions entirely too I suppose...
Another option is to remove the cacheline group from around the xdp_rxq_info struct entirely, since it will get a separate cacheline due to cacheline_aligned...
PATCH v2 3/9 ice: use cacheline groups for ice_tx_ring structure
In reply to Jacob KellerThe ice ring structure was reorganized by commit 65124bbf980c ("ice:
Reorganize tx_buf and ring structs"), and later split into a separate ice_tx_ring structure by commit e72bba21355d ("ice: split ice_ring onto Tx/Rx separate structs").
The ice_tx_ring structure has comments left over from this reorganization and split indicating which fields are supposed to belong to which cachelines. Unfortunately, these comments are almost completely incorrect.
* Cacheline 1 spans from the start of the structure to the vsi pointer. This cacheline is correct, and appears to be the only one that is.
* Cacheline 2 spans from the DMA address down to the xps_state field. The comments indicate it should end at the rcu head field.
* Cacheline 3 spans from the ice_channel pointer to the end of the struct, and completely contains what is marked as a separate 4th cacheline.
The use of such comments to indicate cache lines is error prone. It is extremely likely that the comments will become out of date with future refactors. Instead, use __cacheline_group_(begin|end)_aligned() which is more explicit. It guarantees that members between the cacheline groups will be in distinct cache lines through the use of padding. It additionally enables compile time assertions to help prevent new fields from drastically re-arranging the cache lines.
There are two main issues if we just replace the existing comments with cache line group markers. First, the spinlock_t tx_lock field is 24 bytes on most kernels, but is 64 bytes on CONFIG_DEBUG_LOCK_ALLOC kernels. Ideally we want to place this field at the start of a cacheline so that other fields in the group don't get split across such a debug kernel. While optimizing such a debug kernel is not a priority, doing this makes the assertions around the cacheline a bit easier to understand.
Remove the out-of-date cacheline comments, and add __cacheline_group annotations. These are set to match the existing layout instead of matching the original comments. The only change to layout is to re-order the tx_lock to be the start of cacheline 3, and move txq_teid to avoid a 4-byte gap in the layout.
Ideally, we should profile the Tx hot path and figure out which fields go together and re-arrange the cacheline groups, possibly along "read_mostly", "readwrite" and "cold" groupings similar to the idpf driver. This has been left as an exercise for a later improvement.
Finally, add annotations which check the cacheline sizes. For cacheline 3, we enforce that tx_lock is in this cacheline group, and check the size based on whether or not the CONFIG_DEBUG_LOCK_ALLOC is enabled. Similar to the Rx annotations, these check that the size of each cacheline group (excluding padding) is no greater than 64 bytes. This is primarily intended to produce compiler failures if developers add or re-arrange fields such that cacheline groups exceed the expected 64 byte sizes on x86_64 systems. Because the assertions check the size excluding any padding, they should behave the same even on systems with larger L1 cacheline sizes.
--- drivers/net/ethernet/intel/ice/ice_txrx.h | 32 +++++++++++++++++++++++++------ drivers/net/ethernet/intel/ice/ice_main.c | 1 + 2 files changed, 27 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.h +26 -6
@@ -319,7 +319,7 @@ static inline void ice_rx_ring_struct_check(void) }struct ice_tx_ring { -/* CL1 - 1st cacheline starts here */ +__cacheline_group_begin_aligned (cl1);struct ice_tx_ring *next;/* pointer to next ring in q_vector */ void *desc;/* Descriptor ring memory */ struct device *dev;/* Used for DMA mapping */
@@ -328,7 +328,9 @@ struct ice_tx_ring {struct ice_q_vector *q_vector;/* Backreference to associated vector */ struct net_device *netdev;/* netdev ring maps to */ struct ice_vsi *vsi;/* Backreference to associated VSI */ -/* CL2 - 2nd cacheline starts here */ +__cacheline_group_end_aligned (cl1); + +__cacheline_group_begin_aligned (cl2);dma_addr_t dma;/* physical address of ring */ struct xsk_buff_pool *xsk_pool;u16 next_to_use;
@@ -340,15 +342,18 @@ struct ice_tx_ring {u16 xdp_tx_active;/* stats structs */ struct ice_ring_stats *ring_stats; -/* CL3 - 3rd cacheline starts here */ struct rcu_head rcu;/* to avoid race on free */ DECLARE_BITMAP (xps_state,ICE_TX_NBITS );/* XPS Config State */ +__cacheline_group_end_aligned (cl2); + +__cacheline_group_begin_aligned (cl3); +spinlock_t tx_lock;struct ice_channel *ch;struct ice_ptp_tx *tx_tstamps; -spinlock_t tx_lock; -u32 txq_teid;/* Added Tx queue TEID */ -/* CL4 - 4th cacheline starts here */ struct ice_tstamp_ring *tstamp_ring; + +u32 txq_teid;/* Added Tx queue TEID */ +#define ICE_TX_FLAGS_RING_XDP BIT(0)#define ICE_TX_FLAGS_RING_VLAN_L2TAG1 BIT(1)#define ICE_TX_FLAGS_RING_VLAN_L2TAG2 BIT(2)
@@ -356,8 +361,23 @@ struct ice_tx_ring {u8 flags;u8 dcb_tc;/* Traffic class of ring */ u16 quanta_prof_id; +__cacheline_group_end_aligned (cl3); }____cacheline_internodealigned_in_smp ; +static inline void ice_tx_ring_struct_check (void ) +{ + CACHELINE_ASSERT_GROUP_SIZE(struct ice_tx_ring, cl1, 64); + CACHELINE_ASSERT_GROUP_SIZE(struct ice_tx_ring, cl2, 64); + + CACHELINE_ASSERT_GROUP_MEMBER(struct ice_tx_ring, cl3, tx_lock); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +/* spinlock_t is larger on DEBUG_LOCK_ALLOC kernels */ + CACHELINE_ASSERT_GROUP_SIZE(struct ice_tx_ring, cl3, 128); +#else + CACHELINE_ASSERT_GROUP_SIZE(struct ice_tx_ring, cl3, 64); +#endif +} +static inline bool ice_ring_ch_enabled (struct ice_tx_ring *ring) {return !!ring->ch;
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
@@ -5917,6 +5917,7 @@ static int __init ice_module_init(void)int status = -ENOMEM ;ice_rx_ring_struct_check (); +ice_tx_ring_struct_check ();pr_info ("%s\n" , ice_driver_string);pr_info ("%s\n" , ice_copyright);
Signature · 1 line
2.51.0.rc1.197.g6d975e95c9d7
RE: [PATCH iwl-next v2 3/9] ice: use cacheline groups for ice_tx_ring structure
Quoted 78 lines
-----Original Message-----
From: Keller, Jacob E <[email protected]>
Sent: Wednesday, November 5, 2025 10:07 PM
To: Loktionov, Aleksandr <[email protected]>; Lobakin, Aleksander <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; Keller, Jacob E <[email protected]>
Subject: [PATCH iwl-next v2 3/9] ice: use cacheline groups forice_tx_ringstructureThe ice ring structure was reorganized by commit
65124bbf980c("ice:
Reorganizetx_bufand ring structs"), and later split into a separateice_tx_ringstructure by commite72bba21355d("ice: splitice_ringonto Tx/Rx separate structs").The
ice_tx_ringstructure has comments left over from this reorganization and split indicating which fields are supposed to belong to which cachelines. Unfortunately, these comments are almost completely incorrect.* Cacheline 1 spans from the start of the structure to the vsi
pointer.
This cacheline is correct, and appears to be the only one that is.* Cacheline 2 spans from the DMA address down to the
xps_statefield.
The
comments indicate it should end at the rcu head field.* Cacheline 3 spans from the
ice_channelpointer to the end of the
struct,
and completely contains what is marked as a separate 4th cacheline.The use of such comments to indicate cache lines is error prone. It is extremely likely that the comments will become out of date with future refactors. Instead, use __cacheline_group_(begin|end)_aligned() which is more explicit. It guarantees that members between the cacheline groups will be in distinct cache lines through the use of padding. It additionally enables compile time assertions to help prevent new fields from drastically re-arranging the cache lines.
There are two main issues if we just replace the existing comments with cache line group markers. First, the
spinlock_ttx_lockfield is 24 bytes on most kernels, but is 64 bytes onCONFIG_DEBUG_LOCK_ALLOCkernels.
Ideally we want to place this field at the start of a cacheline so that other fields in the group don't get split across such a debug kernel. While optimizing such a debug kernel is not a priority, doing this makes the assertions around the cacheline a bit easier to understand.Remove the out-of-date cacheline comments, and add
__cacheline_groupannotations. These are set to match the existing layout instead of matching the original comments. The only change to layout is to re- order thetx_lockto be the start of cacheline 3, and movetxq_teidto avoid a 4-byte gap in the layout.Ideally, we should profile the Tx hot path and figure out which fields go together and re-arrange the cacheline groups, possibly along "
read_mostly", "readwrite" and "cold" groupings similar to the idpf driver. This has been left as an exercise for a later improvement.Finally, add annotations which check the cacheline sizes. For cacheline 3, we enforce that
tx_lockis in this cacheline group, and check the size based on whether or not theCONFIG_DEBUG_LOCK_ALLOCis enabled. Similar to the Rx annotations, these check that the size of each cacheline group (excluding padding) is no greater than 64 bytes. This is primarily intended to produce compiler failures if developers add or re-arrange fields such that cacheline groups exceed the expected 64 byte sizes onx86_64systems.
Because the assertions check the size excluding any padding, they should behave the same even on systems with larger L1 cacheline sizes.Signed-off-by Jacob Keller <[email protected]>---
...
Quoted 2 lines
--
2.51.0.rc1.197.g6d975e95c9d7
PATCH v2 4/9 ice: move prev_pkt from ice_txq_stats to ice_tx_ring
In reply to Jacob KellerThe prev_pkt field in ice_txq_stats is used by ice_check_for_hung_subtask as a way to detect potential Tx hangs due to missed interrupts.
The value is based on the packet count, but its an int and not really a "statistic". The value is signed so that we can use -1 as a "no work pending" value. A following change is going to refactor the stats to all use the u64_stat_t type and accessor functions. Leaving prev_pkt as the lone int feels a bit strange.
Instead, move it out of ice_txq_stats and place it in the ice_tx_ring. We have 8 bytes still available in the 3rd cacheline, so this move saves a small amount of memory. It also shouldn't impact the Tx path heavily since its only accessed during initialization and the hang subtask.
--- drivers/net/ethernet/intel/ice/ice_txrx.h | 3 ++- drivers/net/ethernet/intel/ice/ice_main.c | 6 +++--- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.h +2 -1
@@ -138,7 +138,6 @@ struct ice_txq_stats {u64 restart_q;u64 tx_busy;u64 tx_linearize; -int prev_pkt;/* negative if no pending Tx descriptors */ };struct ice_rxq_stats {
@@ -354,6 +353,8 @@ struct ice_tx_ring {u32 txq_teid;/* Added Tx queue TEID */ +int prev_pkt;/* negative if no pending Tx descriptors */ +#define ICE_TX_FLAGS_RING_XDP BIT(0)#define ICE_TX_FLAGS_RING_VLAN_L2TAG1 BIT(1)#define ICE_TX_FLAGS_RING_VLAN_L2TAG2 BIT(2)
drivers/net/ethernet/intel/ice/ice_main.c +3 -3
@@ -160,7 +160,7 @@ static void ice_check_for_hang_subtask(struct ice_pf *pf)* pending work. */ packets = ring_stats->stats.pkts &INT_MAX ; -if (ring_stats->tx_stats.prev_pkt == packets) { +if (tx_ring->prev_pkt == packets) {/* Trigger sw interrupt to revive the queue */ ice_trigger_sw_intr (hw, tx_ring->q_vector);continue ;
@@ -170,8 +170,8 @@ static void ice_check_for_hang_subtask(struct ice_pf *pf)* to ice_get_tx_pending() */ smp_rmb (); - ring_stats->tx_stats.prev_pkt = -ice_get_tx_pending (tx_ring) ? packets :-1 ; + tx_ring->prev_pkt = +ice_get_tx_pending (tx_ring) ? packets :-1 ; } } }
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
@@ -499,7 +499,7 @@ int ice_setup_tx_ring(struct ice_tx_ring *tx_ring) tx_ring->next_to_use =0 ; tx_ring->next_to_clean =0 ; - tx_ring->ring_stats->tx_stats.prev_pkt =-1 ; + tx_ring->prev_pkt =-1 ;return 0 ; err:
Signature · 1 line
2.51.0.rc1.197.g6d975e95c9d7
RE: [PATCH iwl-next v2 4/9] ice: move prev_pkt from ice_txq_stats to ice_tx_ring
Quoted 32 lines
-----Original Message-----
From: Keller, Jacob E <[email protected]>
Sent: Wednesday, November 5, 2025 10:07 PM
To: Loktionov, Aleksandr <[email protected]>; Lobakin, Aleksander <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; Keller, Jacob E <[email protected]>
Subject: [PATCH iwl-next v2 4/9] ice: moveprev_pktfromice_txq_statstoice_tx_ringThe
prev_pktfield inice_txq_statsis used byice_check_for_hung_subtaskas a way to detect potential Tx hangs due to missed interrupts.The value is based on the packet count, but its an int and not really a "statistic". The value is signed so that we can use -1 as a "no work pending" value. A following change is going to refactor the stats to all use the
u64_stat_ttype and accessor functions. Leavingprev_pktas the lone int feels a bit strange.Instead, move it out of
ice_txq_statsand place it in theice_tx_ring. We have 8 bytes still available in the 3rd cacheline, so this move saves a small amount of memory. It also shouldn't impact the Tx path heavily since its only accessed during initialization and the hang subtask.Signed-off-by Jacob Keller <[email protected]>---
...
Quoted 2 lines
--
2.51.0.rc1.197.g6d975e95c9d7
PATCH v2 5/9 ice: pass pointer to ice_fetch_u64_stats_per_ring
In reply to Jacob KellerThe 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.
--- drivers/net/ethernet/intel/ice/ice.h | 3 --- drivers/net/ethernet/intel/ice/ice_main.c | 24 +++++++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +0 -3
@@ -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);
drivers/net/ethernet/intel/ice/ice_main.c +9 -15
@@ -6826,25 +6826,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)); }/**
@@ -6868,9 +6866,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;
@@ -6914,9 +6910,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;
Signature · 1 line
2.51.0.rc1.197.g6d975e95c9d7
PATCH v2 6/9 ice: remove ice_q_stats struct and use struct_group
In reply to Jacob KellerThe ice_qp_reset_stats function resets the stats for all rings on a VSI. It currently behaves differently for Tx and Rx rings. For Rx rings, it only clears the rx_stats which do not include the pkt and byte counts. For Tx rings and XDP rings, it clears only the pkt and byte counts.
We could add extra memset calls to cover both the stats and relevant tx/rx stats fields. Instead, lets convert stats into a struct_group which contains both the pkts and bytes fields as well as the Tx or Rx stats, and remove the ice_q_stats structure entirely.
The only remaining user of ice_q_stats is the ice_q_stats_len function in ice_ethtool.c, which just counts the number of fields. Replace this with a simple multiplication by 2. I find this to be simpler to reason about than relying on knowing the layout of the ice_q_stats structure.
Now that the stats field of the ice_ring_stats covers all of the statistic values, the ice_qp_reset_stats function will properly zero out all of the fields.
--- drivers/net/ethernet/intel/ice/ice_txrx.h | 18 ++++++++---------- drivers/net/ethernet/intel/ice/ice_base.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_ethtool.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_lib.c | 7 ++++--- 4 files changed, 16 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.h +8 -10
@@ -129,11 +129,6 @@ struct ice_tx_offload_params {u8 header_len; }; -struct ice_q_stats { -u64 pkts; -u64 bytes; -}; -struct ice_txq_stats {u64 restart_q;u64 tx_busy;
@@ -148,12 +143,15 @@ struct ice_rxq_stats {struct ice_ring_stats {struct rcu_head rcu;/* to avoid race on free */ -struct ice_q_stats stats;struct u64_stats_sync syncp; -union { -struct ice_txq_stats tx_stats; -struct ice_rxq_stats rx_stats; - }; + struct_group(stats, + u64 pkts; +u64 bytes; +union { +struct ice_txq_stats tx_stats; +struct ice_rxq_stats rx_stats; + }; + ); };enum ice_ring_state_t {
drivers/net/ethernet/intel/ice/ice_base.c +2 -2
@@ -1414,8 +1414,8 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx)if (!vsi_stat)return ; -memset (&vsi_stat->rx_ring_stats[q_idx]->rx_stats,0 , -sizeof (vsi_stat->rx_ring_stats[q_idx]->rx_stats)); +memset (&vsi_stat->rx_ring_stats[q_idx]->stats,0 , +sizeof (vsi_stat->rx_ring_stats[q_idx]->stats));memset (&vsi_stat->tx_ring_stats[q_idx]->stats,0 ,sizeof (vsi_stat->tx_ring_stats[q_idx]->stats));if (vsi->xdp_rings)
drivers/net/ethernet/intel/ice/ice_ethtool.c +2 -2
@@ -33,8 +33,8 @@ static int ice_q_stats_len(struct net_device *netdev) {struct ice_netdev_priv *np =netdev_priv (netdev); -return ((np->vsi->alloc_txq + np->vsi->alloc_rxq) * - (sizeof (struct ice_q_stats ) /sizeof (u64))); +/* One packets and one bytes count per queue */ +return ((np->vsi->alloc_txq + np->vsi->alloc_rxq) *2 ); }#define ICE_PF_STATS_LEN ARRAY_SIZE(ice_gstrings_pf_stats)
drivers/net/ethernet/intel/ice/ice_lib.c +4 -3
@@ -3441,7 +3441,8 @@ int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc)* * This function assumes that caller has acquired a u64_stats_sync lock. */ -static void ice_update_ring_stats (struct ice_q_stats *stats,u64 pkts,u64 bytes) +static void ice_update_ring_stats (struct ice_ring_stats *stats, +u64 pkts,u64 bytes) { stats->bytes += bytes; stats->pkts += pkts;
@@ -3456,7 +3457,7 @@ static void ice_update_ring_stats(struct ice_q_stats *stats, u64 pkts, u64 bytesvoid ice_update_tx_ring_stats (struct ice_tx_ring *tx_ring,u64 pkts,u64 bytes) {u64_stats_update_begin (&tx_ring->ring_stats->syncp); -ice_update_ring_stats (&tx_ring->ring_stats->stats, pkts, bytes); +ice_update_ring_stats (tx_ring->ring_stats, pkts, bytes);u64_stats_update_end (&tx_ring->ring_stats->syncp); }
@@ -3469,7 +3470,7 @@ void ice_update_tx_ring_stats(struct ice_tx_ring *tx_ring, u64 pkts, u64 bytes)void ice_update_rx_ring_stats (struct ice_rx_ring *rx_ring,u64 pkts,u64 bytes) {u64_stats_update_begin (&rx_ring->ring_stats->syncp); -ice_update_ring_stats (&rx_ring->ring_stats->stats, pkts, bytes); +ice_update_ring_stats (rx_ring->ring_stats, pkts, bytes);u64_stats_update_end (&rx_ring->ring_stats->syncp); }
Signature · 1 line
2.51.0.rc1.197.g6d975e95c9d7
PATCH v2 7/9 ice: use u64_stats API to access pkts/bytes in dim sample
In reply to Jacob KellerThe __ice_update_sample and __ice_get_ethtool_stats functions directly accesses the pkts and bytes counters from the ring stats. A following change is going to update the fields to be u64_stats_t type, and will need to be accessed appropriately. This will ensure that the accesses do not cause load/store tearing.
Add helper functions similar to the ones used for updating the stats values, and use them. This ensures use of the syncp pointer on 32-bit architectures. Once the fields are updated to u64_stats_t, it will then properly avoid tears on all architectures.
--- drivers/net/ethernet/intel/ice/ice_lib.h | 6 +++++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 26 +++++++++++++------- drivers/net/ethernet/intel/ice/ice_lib.c | 36 ++++++++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_txrx.c | 29 +++++++++++----------- 4 files changed, 75 insertions(+), 22 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.h +6 -0
@@ -92,6 +92,12 @@ void ice_update_tx_ring_stats(struct ice_tx_ring *ring, u64 pkts, u64 bytes);void ice_update_rx_ring_stats (struct ice_rx_ring *ring,u64 pkts,u64 bytes); +void ice_fetch_tx_ring_stats (const struct ice_tx_ring *ring, +u64 *pkts,u64 *bytes); + +void ice_fetch_rx_ring_stats (const struct ice_rx_ring *ring, +u64 *pkts,u64 *bytes); +void ice_write_intrl (struct ice_q_vector *q_vector,u8 intrl);void ice_write_itr (struct ice_ring_container *rc,u16 itr);void ice_set_q_vector_intrl (struct ice_q_vector *q_vector);
drivers/net/ethernet/intel/ice/ice_ethtool.c +18 -8
@@ -1942,25 +1942,35 @@ __ice_get_ethtool_stats(struct net_device *netdev,rcu_read_lock ();ice_for_each_alloc_txq (vsi, j) { +u64 pkts, bytes; + tx_ring =READ_ONCE (vsi->tx_rings[j]); -if (tx_ring && tx_ring->ring_stats) { - data[i++] = tx_ring->ring_stats->stats.pkts; - data[i++] = tx_ring->ring_stats->stats.bytes; - }else { +if (!tx_ring || !tx_ring->ring_stats) { data[i++] =0 ; data[i++] =0 ; +continue ; } + +ice_fetch_tx_ring_stats (tx_ring, &pkts, &bytes); + + data[i++] = pkts; + data[i++] = bytes; }ice_for_each_alloc_rxq (vsi, j) { +u64 pkts, bytes; + rx_ring =READ_ONCE (vsi->rx_rings[j]); -if (rx_ring && rx_ring->ring_stats) { - data[i++] = rx_ring->ring_stats->stats.pkts; - data[i++] = rx_ring->ring_stats->stats.bytes; - }else { +if (!rx_ring || !rx_ring->ring_stats) { data[i++] =0 ; data[i++] =0 ; +continue ; } + +ice_fetch_rx_ring_stats (rx_ring, &pkts, &bytes); + + data[i++] = pkts; + data[i++] = bytes; }rcu_read_unlock ();
drivers/net/ethernet/intel/ice/ice_lib.c +36 -0
@@ -3474,6 +3474,42 @@ void ice_update_rx_ring_stats(struct ice_rx_ring *rx_ring, u64 pkts, u64 bytes)u64_stats_update_end (&rx_ring->ring_stats->syncp); } +/** +* ice_fetch_tx_ring_stats - Fetch Tx ring packet and byte counters +* @ring: ring to update +* @pkts: number of processed packets +* @bytes: number of processed bytes +*/ +void ice_fetch_tx_ring_stats (const struct ice_tx_ring *ring, +u64 *pkts,u64 *bytes) +{ +unsigned int start; + +do { + start =u64_stats_fetch_begin (&ring->ring_stats->syncp); + *pkts = ring->ring_stats->pkts; + *bytes = ring->ring_stats->bytes; + }while (u64_stats_fetch_retry (&ring->ring_stats->syncp, start)); +} + +/** +* ice_fetch_rx_ring_stats - Fetch Rx ring packet and byte counters +* @ring: ring to read +* @pkts: number of processed packets +* @bytes: number of processed bytes +*/ +void ice_fetch_rx_ring_stats (const struct ice_rx_ring *ring, +u64 *pkts,u64 *bytes) +{ +unsigned int start; + +do { + start =u64_stats_fetch_begin (&ring->ring_stats->syncp); + *pkts = ring->ring_stats->pkts; + *bytes = ring->ring_stats->bytes; + }while (u64_stats_fetch_retry (&ring->ring_stats->syncp, start)); +} +/** * ice_is_dflt_vsi_in_use - check if the default forwarding VSI is being used * @pi: port info of the switch with default VSI
drivers/net/ethernet/intel/ice/ice_txrx.c +15 -14
@@ -1087,35 +1087,36 @@ static void __ice_update_sample(struct ice_q_vector *q_vector, struct dim_sample *sample, bool is_tx) { -u64 packets =0 , bytes =0 ; +u64 total_packets =0 , total_bytes =0 , pkts, bytes;if (is_tx) {struct ice_tx_ring *tx_ring;ice_for_each_tx_ring (tx_ring, *rc) { -struct ice_ring_stats *ring_stats; - - ring_stats = tx_ring->ring_stats; -if (!ring_stats) +if (!tx_ring->ring_stats)continue ; - packets += ring_stats->stats.pkts; - bytes += ring_stats->stats.bytes; + +ice_fetch_tx_ring_stats (tx_ring, &pkts, &bytes); + + total_packets += pkts; + total_bytes += bytes; } }else {struct ice_rx_ring *rx_ring;ice_for_each_rx_ring (rx_ring, *rc) { -struct ice_ring_stats *ring_stats; - - ring_stats = rx_ring->ring_stats; -if (!ring_stats) +if (!rx_ring->ring_stats)continue ; - packets += ring_stats->stats.pkts; - bytes += ring_stats->stats.bytes; + +ice_fetch_rx_ring_stats (rx_ring, &pkts, &bytes); + + total_packets += pkts; + total_bytes += bytes; } } -dim_update_sample (q_vector->total_events, packets, bytes, sample); +dim_update_sample (q_vector->total_events, + total_packets, total_bytes, sample); sample->comp_ctr =0 ;/* if dim settings get stale, like when not updated for 1
Signature · 1 line
2.51.0.rc1.197.g6d975e95c9d7
PATCH v2 8/9 ice: shorten ring stat names and add accessors
In reply to Jacob KellerThe ice Tx/Rx hotpath has a few statistics counters for tracking unexpected events. These values are stored as u64 but are not accumulated using the u64_stats API. This could result in load/tear stores on some architectures. Even some 64-bit architectures could have issues since the fields are not read or written using ACCESS_ONCE or READ_ONCE.
A following change is going to refactor the stats accumulator code to use the u64_stats API for all of these stats, and to use u64_stats_read and u64_stats_inc properly to prevent load/store tears on all architectures.
Using u64_stats_inc and the syncp pointer is slightly verbose and would be duplicated in a number of places in the Tx and Rx hot path. Add accessor macros for the cases where only a single stat value is touched at once. To keep lines short, also shorten the stats names and convert ice_txq_stats and ice_rxq_stats to struct_group.
This will ease the transition to properly using the u64_stats API in the following change.
--- drivers/net/ethernet/intel/ice/ice_txrx.h | 52 +++++++++++++++++++-------- drivers/net/ethernet/intel/ice/ice_txrx_lib.h | 2 +- drivers/net/ethernet/intel/ice/ice_main.c | 12 +++---- drivers/net/ethernet/intel/ice/ice_txrx.c | 14 ++++---- drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 2 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +-- 6 files changed, 55 insertions(+), 31 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.h +38 -14
@@ -129,18 +129,6 @@ struct ice_tx_offload_params {u8 header_len; }; -struct ice_txq_stats { -u64 restart_q; -u64 tx_busy; -u64 tx_linearize; -}; - -struct ice_rxq_stats { -u64 non_eop_descs; -u64 alloc_page_failed; -u64 alloc_buf_failed; -}; -struct ice_ring_stats {struct rcu_head rcu;/* to avoid race on free */ struct u64_stats_sync syncp;
@@ -148,12 +136,48 @@ struct ice_ring_stats {u64 pkts;u64 bytes;union { -struct ice_txq_stats tx_stats; -struct ice_rxq_stats rx_stats; + struct_group(tx, + u64 tx_restart_q; +u64 tx_busy; +u64 tx_linearize; + ); + struct_group(rx, + u64 rx_non_eop_descs; +u64 rx_page_failed; +u64 rx_buf_failed; + ); }; ); }; +/** +* ice_stats_read - Read a single ring stat value +* @stats: pointer to ring_stats structure for a queue +* @member: the ice_ring_stats member to read +* +* Shorthand for reading a single 64-bit stat value from struct +* ice_ring_stats. +* +* Return: the value of the requested stat. +*/ +#define ice_stats_read (stats, member) ({ \ + struct ice_ring_stats *__stats = (stats); \ + __stats->member; \ +}) + +/** +* ice_stats_inc - Increment a single ring stat value +* @stats: pointer to the ring_stats structure for a queue +* @member: the ice_ring_stats member to increment +* +* Shorthand for incrementing a single 64-bit stat value in struct +* ice_ring_stats. +*/ +#define ice_stats_inc (stats, member) do { \ + struct ice_ring_stats *__stats = (stats); \ + __stats->member++; \ +} while (0) +enum ice_ring_state_t {ICE_TX_XPS_INIT_DONE ,ICE_TX_NBITS ,
drivers/net/ethernet/intel/ice/ice_txrx_lib.h +1 -1
@@ -38,7 +38,7 @@ ice_is_non_eop(const struct ice_rx_ring *rx_ring,if (likely (ice_test_staterr (rx_desc->wb.status_error0,ICE_RXD_EOF )))return false; - rx_ring->ring_stats->rx_stats.non_eop_descs++; +ice_stats_inc (rx_ring->ring_stats, rx_non_eop_descs);return true; }
drivers/net/ethernet/intel/ice/ice_main.c +6 -6
@@ -159,7 +159,7 @@ static void ice_check_for_hang_subtask(struct ice_pf *pf)* prev_pkt would be negative if there was no * pending work. */ - packets = ring_stats->stats.pkts &INT_MAX ; + packets =ice_stats_read (ring_stats, pkts) &INT_MAX ;if (tx_ring->prev_pkt == packets) {/* Trigger sw interrupt to revive the queue */ ice_trigger_sw_intr (hw, tx_ring->q_vector);
@@ -6869,9 +6869,9 @@ ice_update_vsi_tx_ring_stats(struct ice_vsi *vsi,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; - vsi->tx_busy += ring->ring_stats->tx_stats.tx_busy; - vsi->tx_linearize += ring->ring_stats->tx_stats.tx_linearize; + vsi->tx_restart += ring->ring_stats->tx_restart_q; + vsi->tx_busy += ring->ring_stats->tx_busy; + vsi->tx_linearize += ring->ring_stats->tx_linearize; } }
@@ -6913,8 +6913,8 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi)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; - vsi->rx_page_failed += ring_stats->rx_stats.alloc_page_failed; + vsi->rx_buf_failed += ring_stats->rx_buf_failed; + vsi->rx_page_failed += ring_stats->rx_page_failed; }/* update XDP Tx rings counters */
drivers/net/ethernet/intel/ice/ice_txrx.c +7 -7
@@ -379,7 +379,7 @@ static bool ice_clean_tx_irq(struct ice_tx_ring *tx_ring, int napi_budget)if (netif_tx_queue_stopped (txring_txq (tx_ring)) && !test_bit (ICE_VSI_DOWN , vsi->state)) {netif_tx_wake_queue (txring_txq (tx_ring)); - ++tx_ring->ring_stats->tx_stats.restart_q; +ice_stats_inc (tx_ring->ring_stats, tx_restart_q); } }
@@ -849,7 +849,7 @@ bool ice_alloc_rx_bufs(struct ice_rx_ring *rx_ring, unsigned int cleaned_count) addr =libeth_rx_alloc (&fq, ntu);if (addr ==DMA_MAPPING_ERROR ) { - rx_ring->ring_stats->rx_stats.alloc_page_failed++; +ice_stats_inc (rx_ring->ring_stats, rx_page_failed);break ; }
@@ -863,7 +863,7 @@ bool ice_alloc_rx_bufs(struct ice_rx_ring *rx_ring, unsigned int cleaned_count) addr =libeth_rx_alloc (&hdr_fq, ntu);if (addr ==DMA_MAPPING_ERROR ) { - rx_ring->ring_stats->rx_stats.alloc_page_failed++; +ice_stats_inc (rx_ring->ring_stats, rx_page_failed);libeth_rx_recycle_slow (fq.fqes[ntu].netmem);break ;
@@ -1045,7 +1045,7 @@ static int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)/* exit if we failed to retrieve a buffer */ if (!skb) {libeth_xdp_return_buff_slow (xdp); - rx_ring->ring_stats->rx_stats.alloc_buf_failed++; +ice_stats_inc (rx_ring->ring_stats, rx_buf_failed);continue ; }
@@ -1363,7 +1363,7 @@ static int __ice_maybe_stop_tx(struct ice_tx_ring *tx_ring, unsigned int size)/* A reprieve! - use start_queue because it doesn't call schedule */ netif_tx_start_queue (txring_txq (tx_ring)); - ++tx_ring->ring_stats->tx_stats.restart_q; +ice_stats_inc (tx_ring->ring_stats, tx_restart_q);return 0 ; }
@@ -2165,7 +2165,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_tx_ring *tx_ring)if (__skb_linearize (skb)) goto out_drop; count =ice_txd_use_count (skb->len); - tx_ring->ring_stats->tx_stats.tx_linearize++; +ice_stats_inc (tx_ring->ring_stats, tx_linearize); }/* need: 1 descriptor per page * PAGE_SIZE/ICE_MAX_DATA_PER_TXD,
@@ -2176,7 +2176,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_tx_ring *tx_ring)*/ if (ice_maybe_stop_tx (tx_ring, count +ICE_DESCS_PER_CACHE_LINE +ICE_DESCS_FOR_CTX_DESC )) { - tx_ring->ring_stats->tx_stats.tx_busy++; +ice_stats_inc (tx_ring->ring_stats, tx_busy);return NETDEV_TX_BUSY ; }
drivers/net/ethernet/intel/ice/ice_txrx_lib.c +1 -1
@@ -480,7 +480,7 @@ int __ice_xmit_xdp_ring(struct xdp_buff *xdp, struct ice_tx_ring *xdp_ring,return ICE_XDP_CONSUMED ; busy: - xdp_ring->ring_stats->tx_stats.tx_busy++; +ice_stats_inc (xdp_ring->ring_stats, tx_busy);return ICE_XDP_CONSUMED ; }
drivers/net/ethernet/intel/ice/ice_xsk.c +2 -2
@@ -497,7 +497,7 @@ static int ice_xmit_xdp_tx_zc(struct xdp_buff *xdp,return ICE_XDP_TX ; busy: - xdp_ring->ring_stats->tx_stats.tx_busy++; +ice_stats_inc (xdp_ring->ring_stats, tx_busy);return ICE_XDP_CONSUMED ; }
@@ -659,7 +659,7 @@ int ice_clean_rx_irq_zc(struct ice_rx_ring *rx_ring,xsk_buff_free (first); first =NULL ; - rx_ring->ring_stats->rx_stats.alloc_buf_failed++; +ice_stats_inc (rx_ring->ring_stats, rx_buf_failed);continue ; }
Signature · 1 line
2.51.0.rc1.197.g6d975e95c9d7
RE: [PATCH iwl-next v2 8/9] ice: shorten ring stat names and add accessors
Quoted 37 lines
-----Original Message-----
From: Keller, Jacob E <[email protected]>
Sent: Wednesday, November 5, 2025 10:07 PM
To: Loktionov, Aleksandr <[email protected]>; Lobakin, Aleksander <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; Keller, Jacob E <[email protected]>
Subject: [PATCH iwl-next v2 8/9] ice: shorten ring stat names and add accessorsThe ice Tx/Rx hotpath has a few statistics counters for tracking unexpected events. These values are stored as u64 but are not accumulated using the
u64_statsAPI. This could result in load/tear stores on some architectures.
Even some 64-bit architectures could have issues since the fields are not read or written usingACCESS_ONCEorREAD_ONCE.A following change is going to refactor the stats accumulator code to use the
u64_statsAPI for all of these stats, and to useu64_stats_readandu64_stats_incproperly to prevent load/store tears on all architectures.Using
u64_stats_incand the syncp pointer is slightly verbose and would be duplicated in a number of places in the Tx and Rx hot path. Add accessor macros for the cases where only a single stat value is touched at once. To keep lines short, also shorten the stats names and convertice_txq_statsandice_rxq_statstostruct_group.This will ease the transition to properly using the
u64_statsAPI in the following change.Signed-off-by Jacob Keller <[email protected]>---
...
Quoted 2 lines
--
2.51.0.rc1.197.g6d975e95c9d7
PATCH v2 9/9 ice: convert all ring stats to u64_stats_t
In reply to Jacob KellerAfter several cleanups, the ice driver is now finally ready to convert all Tx and Rx ring stats to the u64_stats_t and proper use of the u64 stats APIs.
The final remaining part to cleanup is the VSI stats accumulation logic in ice_update_vsi_ring_stats().
Refactor the function and its helpers so that all stat values (and not just pkts and bytes) use the u64_stats APIs. The ice_fetch_u64_(tx|rx)_stats functions read the stat values using u64_stats_read and then copy them into local ice_vsi_(tx|rx)_stats structures. This does require making a new struct with the stat fields as u64.
The ice_update_vsi_(tx|rx)_ring_stats functions call the fetch functions per ring and accumulate the result into one copy of the struct. This accumulated total is then used to update the relevant VSI fields.
Since these are relatively small, the contents are all stored on the stack rather than allocating and freeing memory.
Once the accumulator side is updated, the helper ice_stats_read and ice_stats_inc and other related helper functions all easily translate to use of u64_stats_read and u64_stats_inc. This completes the refactor and ensures that all stats accesses now make proper use of the API.
--- drivers/net/ethernet/intel/ice/ice_txrx.h | 28 +++-- drivers/net/ethernet/intel/ice/ice_lib.c | 29 ++--- drivers/net/ethernet/intel/ice/ice_main.c | 180 ++++++++++++++++++++---------- 3 files changed, 147 insertions(+), 90 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.h +18 -10
@@ -133,18 +133,18 @@ struct ice_ring_stats {struct rcu_head rcu;/* to avoid race on free */ struct u64_stats_sync syncp;struct_group (stats, - u64 pkts; - u64 bytes; + u64_stats_t pkts; + u64_stats_t bytes; union {struct_group (tx, - u64 tx_restart_q; - u64 tx_busy; - u64 tx_linearize; + u64_stats_t tx_restart_q; + u64_stats_t tx_busy; + u64_stats_t tx_linearize; );struct_group (rx, - u64 rx_non_eop_descs; - u64 rx_page_failed; - u64 rx_buf_failed; + u64_stats_t rx_non_eop_descs; + u64_stats_t rx_page_failed; + u64_stats_t rx_buf_failed; ); }; );
@@ -162,7 +162,13 @@ struct ice_ring_stats {*/ #define ice_stats_read (stats, member) ({ \ struct ice_ring_stats *__stats = (stats); \ - __stats->member; \ + unsigned int start; \ + u64 val; \ + do { \ + start = u64_stats_fetch_begin(&__stats->syncp); \ + val = u64_stats_read(&__stats->member); \ + } while (u64_stats_fetch_retry(&__stats->syncp, start)); \ + val; \ })/**
@@ -175,7 +181,9 @@ struct ice_ring_stats {*/ #define ice_stats_inc (stats, member) do { \ struct ice_ring_stats *__stats = (stats); \ - __stats->member++; \ + u64_stats_update_begin(&__stats->syncp); \ + u64_stats_inc(&__stats->member); \ + u64_stats_update_end(&__stats->syncp); \ } while (0)enum ice_ring_state_t {
drivers/net/ethernet/intel/ice/ice_lib.c +8 -21
@@ -3433,21 +3433,6 @@ int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc)return ret; } -/** -* ice_update_ring_stats - Update ring statistics -* @stats: stats to be updated -* @pkts: number of processed packets -* @bytes: number of processed bytes -* -* This function assumes that caller has acquired a u64_stats_sync lock. -*/ -static void ice_update_ring_stats (struct ice_ring_stats *stats, -u64 pkts,u64 bytes) -{ - stats->bytes += bytes; - stats->pkts += pkts; -} -/** * ice_update_tx_ring_stats - Update Tx ring specific counters * @tx_ring: ring to update
@@ -3457,7 +3442,8 @@ static void ice_update_ring_stats(struct ice_ring_stats *stats,void ice_update_tx_ring_stats (struct ice_tx_ring *tx_ring,u64 pkts,u64 bytes) {u64_stats_update_begin (&tx_ring->ring_stats->syncp); -ice_update_ring_stats (tx_ring->ring_stats, pkts, bytes); +u64_stats_add (&tx_ring->ring_stats->pkts, pkts); +u64_stats_add (&tx_ring->ring_stats->bytes, bytes);u64_stats_update_end (&tx_ring->ring_stats->syncp); }
@@ -3470,7 +3456,8 @@ void ice_update_tx_ring_stats(struct ice_tx_ring *tx_ring, u64 pkts, u64 bytes)void ice_update_rx_ring_stats (struct ice_rx_ring *rx_ring,u64 pkts,u64 bytes) {u64_stats_update_begin (&rx_ring->ring_stats->syncp); -ice_update_ring_stats (rx_ring->ring_stats, pkts, bytes); +u64_stats_add (&rx_ring->ring_stats->pkts, pkts); +u64_stats_add (&rx_ring->ring_stats->bytes, bytes);u64_stats_update_end (&rx_ring->ring_stats->syncp); }
@@ -3487,8 +3474,8 @@ void ice_fetch_tx_ring_stats(const struct ice_tx_ring *ring,do { start =u64_stats_fetch_begin (&ring->ring_stats->syncp); - *pkts = ring->ring_stats->pkts; - *bytes = ring->ring_stats->bytes; + *pkts =u64_stats_read (&ring->ring_stats->pkts); + *bytes =u64_stats_read (&ring->ring_stats->bytes); }while (u64_stats_fetch_retry (&ring->ring_stats->syncp, start)); }
@@ -3505,8 +3492,8 @@ void ice_fetch_rx_ring_stats(const struct ice_rx_ring *ring,do { start =u64_stats_fetch_begin (&ring->ring_stats->syncp); - *pkts = ring->ring_stats->pkts; - *bytes = ring->ring_stats->bytes; + *pkts =u64_stats_read (&ring->ring_stats->pkts); + *bytes =u64_stats_read (&ring->ring_stats->bytes); }while (u64_stats_fetch_retry (&ring->ring_stats->syncp, start)); }
drivers/net/ethernet/intel/ice/ice_main.c +121 -59
241 lines not on this page · raw message
Signature · 1 line
2.51.0.rc1.197.g6d975e95c9d7