diff options
| author | Daniel Zahka <daniel.zahka@gmail.com> | 2026-05-29 16:15:28 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-06-02 22:57:46 +0300 |
| commit | 163bea8010bdf785b6dadeab0cb199e94e1f99bd (patch) | |
| tree | cc1c43358e02b8f955e15d8ce9b11768c5fb267e /drivers/net/netdevsim/netdevsim.h | |
| parent | abaef7e966fdc236ee57ea30c019365110d00f48 (diff) | |
| download | linux-163bea8010bdf785b6dadeab0cb199e94e1f99bd.tar.xz | |
netdevsim: psp: use atomic64 for psp stats counters
The existing u64_stats_t-based psp counters had two preexisting api
usage bugs: u64_stats_init() was never called on the syncp object, and
the writer side of the u64_stats_update_begin()/end() api was not
serialized. Switch the counters to atomic64_t instead. Atomics need
no initialization and are inherently safe against concurrent writers,
eliminating both bugs at once.
Use atomic64_t rather than atomic_long_t so byte counters don't wrap
at 4 GiB on 32-bit builds.
Fixes: 178f0763c5f3 ("netdevsim: implement psp device stats")
Cc: <stable+noautosel@kernel.org> # netdevsim is a test harness, it's never loaded on production systems
Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260529-fix-psp-stats-v2-2-3a194eacf18e@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/netdevsim/netdevsim.h')
| -rw-r--r-- | drivers/net/netdevsim/netdevsim.h | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index d909c4160ea1..4c9cc96dcec3 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -22,7 +22,6 @@ #include <linux/list.h> #include <linux/netdevice.h> #include <linux/ptp_mock.h> -#include <linux/u64_stats_sync.h> #include <net/devlink.h> #include <net/udp_tunnel.h> #include <net/xdp.h> @@ -115,11 +114,10 @@ struct netdevsim { int rq_reset_mode; struct { - u64_stats_t rx_packets; - u64_stats_t rx_bytes; - u64_stats_t tx_packets; - u64_stats_t tx_bytes; - struct u64_stats_sync syncp; + atomic64_t rx_packets; + atomic64_t rx_bytes; + atomic64_t tx_packets; + atomic64_t tx_bytes; struct psp_dev __rcu *dev; struct dentry *rereg; struct mutex rereg_lock; |
