* [PATCH net-next] net: ifb: use u64_stats_t with u64_stats_sync properly
@ 2026-01-21 8:23 David Yang
2026-01-22 12:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: David Yang @ 2026-01-21 8:23 UTC (permalink / raw)
To: netdev
Cc: David Yang, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-kernel
On 64bit arches, struct u64_stats_sync is empty and provides no help
against load/store tearing. Convert to u64_stats_t to ensure atomic
operations.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/ifb.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index d3dc0914450a..6da801748189 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -39,8 +39,8 @@
#define TX_Q_LIMIT 32
struct ifb_q_stats {
- u64 packets;
- u64 bytes;
+ u64_stats_t packets;
+ u64_stats_t bytes;
struct u64_stats_sync sync;
};
@@ -81,8 +81,8 @@ static int ifb_close(struct net_device *dev);
static void ifb_update_q_stats(struct ifb_q_stats *stats, int len)
{
u64_stats_update_begin(&stats->sync);
- stats->packets++;
- stats->bytes += len;
+ u64_stats_inc(&stats->packets);
+ u64_stats_add(&stats->bytes, len);
u64_stats_update_end(&stats->sync);
}
@@ -163,16 +163,16 @@ static void ifb_stats64(struct net_device *dev,
for (i = 0; i < dev->num_tx_queues; i++,txp++) {
do {
start = u64_stats_fetch_begin(&txp->rx_stats.sync);
- packets = txp->rx_stats.packets;
- bytes = txp->rx_stats.bytes;
+ packets = u64_stats_read(&txp->rx_stats.packets);
+ bytes = u64_stats_read(&txp->rx_stats.bytes);
} while (u64_stats_fetch_retry(&txp->rx_stats.sync, start));
stats->rx_packets += packets;
stats->rx_bytes += bytes;
do {
start = u64_stats_fetch_begin(&txp->tx_stats.sync);
- packets = txp->tx_stats.packets;
- bytes = txp->tx_stats.bytes;
+ packets = u64_stats_read(&txp->tx_stats.packets);
+ bytes = u64_stats_read(&txp->tx_stats.bytes);
} while (u64_stats_fetch_retry(&txp->tx_stats.sync, start));
stats->tx_packets += packets;
stats->tx_bytes += bytes;
@@ -248,7 +248,7 @@ static void ifb_fill_stats_data(u64 **data,
start = u64_stats_fetch_begin(&q_stats->sync);
for (j = 0; j < IFB_Q_STATS_LEN; j++) {
offset = ifb_q_stats_desc[j].offset;
- (*data)[j] = *(u64 *)(stats_base + offset);
+ (*data)[j] = u64_stats_read((u64_stats_t *)(stats_base + offset));
}
} while (u64_stats_fetch_retry(&q_stats->sync, start));
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: ifb: use u64_stats_t with u64_stats_sync properly
2026-01-21 8:23 [PATCH net-next] net: ifb: use u64_stats_t with u64_stats_sync properly David Yang
@ 2026-01-22 12:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-22 12:10 UTC (permalink / raw)
To: Yangfl; +Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Wed, 21 Jan 2026 16:23:44 +0800 you wrote:
> On 64bit arches, struct u64_stats_sync is empty and provides no help
> against load/store tearing. Convert to u64_stats_t to ensure atomic
> operations.
>
> Signed-off-by: David Yang <mmyangfl@gmail.com>
> ---
> drivers/net/ifb.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
Here is the summary with links:
- [net-next] net: ifb: use u64_stats_t with u64_stats_sync properly
https://git.kernel.org/netdev/net-next/c/cbe38d2e52cf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-22 12:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21 8:23 [PATCH net-next] net: ifb: use u64_stats_t with u64_stats_sync properly David Yang
2026-01-22 12:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox