From: Jacob Keller <jacob.e.keller@intel.com>
To: Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Simon Horman <horms@kernel.org>,
intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
Jacob Keller <jacob.e.keller@intel.com>,
Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Subject: [PATCH iwl-next v4 0/6] ice: properly use u64_stats API for all ring stats
Date: Thu, 20 Nov 2025 12:20:40 -0800 [thread overview]
Message-ID: <20251120-jk-refactor-queue-stats-v4-0-6e8b0cea75cc@intel.com> (raw)
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 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.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
Changes in v4:
- Drop the cacheline_group changes. Olek and I plan to work on a full
solution in a separate series.
- Drop moving prev_pkt out of the stats. This might still be a good idea,
but it should wait for the cacheline group changes.
- Link to v3: https://patch.msgid.link/20251107-jk-refactor-queue-stats-v3-0-771ae1414b2e@intel.com
Changes in v3:
- Use SMP_CACHE_BYTES in assertions to avoid issues on ARM v7 with 128-byte
cache (due to xdp_rxq_info changing size)
- Only check the tx_lock cache group size for non-debug kernels, rather
than keeping logic to check its size when DEBUG_LOCK_ALLOC is enabled.
- Link to v2: https://patch.msgid.link/20251105-jk-refactor-queue-stats-v2-0-8652557f9572@intel.com
Changes in v2:
- Fix minor typos.
- Link to v1: https://patch.msgid.link/20251103-jk-refactor-queue-stats-v1-0-164d2ed859b6@intel.com
---
Jacob Keller (6):
ice: initialize ring_stats->syncp
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 | 77 +++++++---
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 | 196 +++++++++++++++++---------
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, 280 insertions(+), 150 deletions(-)
---
base-commit: 2fcc88754f4c49e3d9aef226fdfaa1634aa24c66
change-id: 20251016-jk-refactor-queue-stats-9e721b34ce01
Best regards,
--
Jacob Keller <jacob.e.keller@intel.com>
next reply other threads:[~2025-11-20 20:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 20:20 Jacob Keller [this message]
2025-11-20 20:20 ` [PATCH iwl-next v4 1/6] ice: initialize ring_stats->syncp Jacob Keller
2025-11-25 10:15 ` Simon Horman
2025-12-03 22:23 ` Jacob Keller
2025-12-04 12:13 ` Simon Horman
2025-12-18 10:50 ` [Intel-wired-lan] " Rinitha, SX
2025-11-20 20:20 ` [PATCH iwl-next v4 2/6] ice: pass pointer to ice_fetch_u64_stats_per_ring Jacob Keller
2025-11-25 10:16 ` Simon Horman
2025-12-03 22:12 ` Jacob Keller
2025-12-18 10:50 ` [Intel-wired-lan] " Rinitha, SX
2025-11-20 20:20 ` [PATCH iwl-next v4 3/6] ice: remove ice_q_stats struct and use struct_group Jacob Keller
2025-11-25 10:16 ` Simon Horman
2025-12-03 22:14 ` Jacob Keller
2025-12-18 10:50 ` [Intel-wired-lan] " Rinitha, SX
2025-11-20 20:20 ` [PATCH iwl-next v4 4/6] ice: use u64_stats API to access pkts/bytes in dim sample Jacob Keller
2025-11-25 10:17 ` Simon Horman
2025-12-18 10:51 ` [Intel-wired-lan] " Rinitha, SX
2025-11-20 20:20 ` [PATCH iwl-next v4 5/6] ice: shorten ring stat names and add accessors Jacob Keller
2025-11-25 10:17 ` Simon Horman
2025-12-03 22:17 ` Jacob Keller
2025-12-18 10:51 ` [Intel-wired-lan] " Rinitha, SX
2025-11-20 20:20 ` [PATCH iwl-next v4 6/6] ice: convert all ring stats to u64_stats_t Jacob Keller
2025-11-25 10:17 ` Simon Horman
2025-12-03 22:21 ` Jacob Keller
2025-12-18 10:51 ` [Intel-wired-lan] " Rinitha, SX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251120-jk-refactor-queue-stats-v4-0-6e8b0cea75cc@intel.com \
--to=jacob.e.keller@intel.com \
--cc=aleksander.lobakin@intel.com \
--cc=aleksandr.loktionov@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=netdev@vger.kernel.org \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).