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

team: adopt u64_stats_t

As explained in commit 316580b69d0a ("u64_stats: provide u64_stats_t type")
we should use u64_stats_t and related accessors to avoid load/store tearing.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
9ec321ab c6cce71e

+18 -18
+13 -13
drivers/net/team/team.c
··· 749 749 750 750 pcpu_stats = this_cpu_ptr(team->pcpu_stats); 751 751 u64_stats_update_begin(&pcpu_stats->syncp); 752 - pcpu_stats->rx_packets++; 753 - pcpu_stats->rx_bytes += skb->len; 752 + u64_stats_inc(&pcpu_stats->rx_packets); 753 + u64_stats_add(&pcpu_stats->rx_bytes, skb->len); 754 754 if (skb->pkt_type == PACKET_MULTICAST) 755 - pcpu_stats->rx_multicast++; 755 + u64_stats_inc(&pcpu_stats->rx_multicast); 756 756 u64_stats_update_end(&pcpu_stats->syncp); 757 757 758 758 skb->dev = team->dev; ··· 1720 1720 1721 1721 pcpu_stats = this_cpu_ptr(team->pcpu_stats); 1722 1722 u64_stats_update_begin(&pcpu_stats->syncp); 1723 - pcpu_stats->tx_packets++; 1724 - pcpu_stats->tx_bytes += len; 1723 + u64_stats_inc(&pcpu_stats->tx_packets); 1724 + u64_stats_add(&pcpu_stats->tx_bytes, len); 1725 1725 u64_stats_update_end(&pcpu_stats->syncp); 1726 1726 } else { 1727 1727 this_cpu_inc(team->pcpu_stats->tx_dropped); ··· 1854 1854 p = per_cpu_ptr(team->pcpu_stats, i); 1855 1855 do { 1856 1856 start = u64_stats_fetch_begin_irq(&p->syncp); 1857 - rx_packets = p->rx_packets; 1858 - rx_bytes = p->rx_bytes; 1859 - rx_multicast = p->rx_multicast; 1860 - tx_packets = p->tx_packets; 1861 - tx_bytes = p->tx_bytes; 1857 + rx_packets = u64_stats_read(&p->rx_packets); 1858 + rx_bytes = u64_stats_read(&p->rx_bytes); 1859 + rx_multicast = u64_stats_read(&p->rx_multicast); 1860 + tx_packets = u64_stats_read(&p->tx_packets); 1861 + tx_bytes = u64_stats_read(&p->tx_bytes); 1862 1862 } while (u64_stats_fetch_retry_irq(&p->syncp, start)); 1863 1863 1864 1864 stats->rx_packets += rx_packets; ··· 1870 1870 * rx_dropped, tx_dropped & rx_nohandler are u32, 1871 1871 * updated without syncp protection. 1872 1872 */ 1873 - rx_dropped += p->rx_dropped; 1874 - tx_dropped += p->tx_dropped; 1875 - rx_nohandler += p->rx_nohandler; 1873 + rx_dropped += READ_ONCE(p->rx_dropped); 1874 + tx_dropped += READ_ONCE(p->tx_dropped); 1875 + rx_nohandler += READ_ONCE(p->rx_nohandler); 1876 1876 } 1877 1877 stats->rx_dropped = rx_dropped; 1878 1878 stats->tx_dropped = tx_dropped;
+5 -5
include/linux/if_team.h
··· 12 12 #include <uapi/linux/if_team.h> 13 13 14 14 struct team_pcpu_stats { 15 - u64 rx_packets; 16 - u64 rx_bytes; 17 - u64 rx_multicast; 18 - u64 tx_packets; 19 - u64 tx_bytes; 15 + u64_stats_t rx_packets; 16 + u64_stats_t rx_bytes; 17 + u64_stats_t rx_multicast; 18 + u64_stats_t tx_packets; 19 + u64_stats_t tx_bytes; 20 20 struct u64_stats_sync syncp; 21 21 u32 rx_dropped; 22 22 u32 tx_dropped;