Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xen/netfront: Use u64_stats_t with u64_stats_sync properly

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>
Link: https://patch.msgid.link/20260121082550.2389249-1-mmyangfl@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

David Yang and committed by
Paolo Abeni
a2ba9902 cbe38d2e

+12 -12
+12 -12
drivers/net/xen-netfront.c
··· 97 97 static DECLARE_WAIT_QUEUE_HEAD(module_wq); 98 98 99 99 struct netfront_stats { 100 - u64 packets; 101 - u64 bytes; 100 + u64_stats_t packets; 101 + u64_stats_t bytes; 102 102 struct u64_stats_sync syncp; 103 103 }; 104 104 ··· 634 634 notify_remote_via_irq(queue->tx_irq); 635 635 636 636 u64_stats_update_begin(&tx_stats->syncp); 637 - tx_stats->bytes += xdpf->len; 638 - tx_stats->packets++; 637 + u64_stats_add(&tx_stats->bytes, xdpf->len); 638 + u64_stats_inc(&tx_stats->packets); 639 639 u64_stats_update_end(&tx_stats->syncp); 640 640 641 641 return 0; ··· 843 843 notify_remote_via_irq(queue->tx_irq); 844 844 845 845 u64_stats_update_begin(&tx_stats->syncp); 846 - tx_stats->bytes += skb->len; 847 - tx_stats->packets++; 846 + u64_stats_add(&tx_stats->bytes, skb->len); 847 + u64_stats_inc(&tx_stats->packets); 848 848 u64_stats_update_end(&tx_stats->syncp); 849 849 850 850 if (!netfront_tx_slot_available(queue)) ··· 1249 1249 } 1250 1250 1251 1251 u64_stats_update_begin(&rx_stats->syncp); 1252 - rx_stats->packets++; 1253 - rx_stats->bytes += skb->len; 1252 + u64_stats_inc(&rx_stats->packets); 1253 + u64_stats_add(&rx_stats->bytes, skb->len); 1254 1254 u64_stats_update_end(&rx_stats->syncp); 1255 1255 1256 1256 /* Pass it up. */ ··· 1400 1400 1401 1401 do { 1402 1402 start = u64_stats_fetch_begin(&tx_stats->syncp); 1403 - tx_packets = tx_stats->packets; 1404 - tx_bytes = tx_stats->bytes; 1403 + tx_packets = u64_stats_read(&tx_stats->packets); 1404 + tx_bytes = u64_stats_read(&tx_stats->bytes); 1405 1405 } while (u64_stats_fetch_retry(&tx_stats->syncp, start)); 1406 1406 1407 1407 do { 1408 1408 start = u64_stats_fetch_begin(&rx_stats->syncp); 1409 - rx_packets = rx_stats->packets; 1410 - rx_bytes = rx_stats->bytes; 1409 + rx_packets = u64_stats_read(&rx_stats->packets); 1410 + rx_bytes = u64_stats_read(&rx_stats->bytes); 1411 1411 } while (u64_stats_fetch_retry(&rx_stats->syncp, start)); 1412 1412 1413 1413 tot->rx_packets += rx_packets;