Commit 9ec321ab authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

team: adopt u64_stats_t

As explained in commit 316580b6 ("u64_stats: provide u64_stats_t type")
we should use u64_stats_t and related accessors to avoid load/store tearing.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c6cce71e
...@@ -749,10 +749,10 @@ static rx_handler_result_t team_handle_frame(struct sk_buff **pskb) ...@@ -749,10 +749,10 @@ static rx_handler_result_t team_handle_frame(struct sk_buff **pskb)
pcpu_stats = this_cpu_ptr(team->pcpu_stats); pcpu_stats = this_cpu_ptr(team->pcpu_stats);
u64_stats_update_begin(&pcpu_stats->syncp); u64_stats_update_begin(&pcpu_stats->syncp);
pcpu_stats->rx_packets++; u64_stats_inc(&pcpu_stats->rx_packets);
pcpu_stats->rx_bytes += skb->len; u64_stats_add(&pcpu_stats->rx_bytes, skb->len);
if (skb->pkt_type == PACKET_MULTICAST) if (skb->pkt_type == PACKET_MULTICAST)
pcpu_stats->rx_multicast++; u64_stats_inc(&pcpu_stats->rx_multicast);
u64_stats_update_end(&pcpu_stats->syncp); u64_stats_update_end(&pcpu_stats->syncp);
skb->dev = team->dev; skb->dev = team->dev;
...@@ -1720,8 +1720,8 @@ static netdev_tx_t team_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1720,8 +1720,8 @@ static netdev_tx_t team_xmit(struct sk_buff *skb, struct net_device *dev)
pcpu_stats = this_cpu_ptr(team->pcpu_stats); pcpu_stats = this_cpu_ptr(team->pcpu_stats);
u64_stats_update_begin(&pcpu_stats->syncp); u64_stats_update_begin(&pcpu_stats->syncp);
pcpu_stats->tx_packets++; u64_stats_inc(&pcpu_stats->tx_packets);
pcpu_stats->tx_bytes += len; u64_stats_add(&pcpu_stats->tx_bytes, len);
u64_stats_update_end(&pcpu_stats->syncp); u64_stats_update_end(&pcpu_stats->syncp);
} else { } else {
this_cpu_inc(team->pcpu_stats->tx_dropped); this_cpu_inc(team->pcpu_stats->tx_dropped);
...@@ -1854,11 +1854,11 @@ team_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) ...@@ -1854,11 +1854,11 @@ team_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
p = per_cpu_ptr(team->pcpu_stats, i); p = per_cpu_ptr(team->pcpu_stats, i);
do { do {
start = u64_stats_fetch_begin_irq(&p->syncp); start = u64_stats_fetch_begin_irq(&p->syncp);
rx_packets = p->rx_packets; rx_packets = u64_stats_read(&p->rx_packets);
rx_bytes = p->rx_bytes; rx_bytes = u64_stats_read(&p->rx_bytes);
rx_multicast = p->rx_multicast; rx_multicast = u64_stats_read(&p->rx_multicast);
tx_packets = p->tx_packets; tx_packets = u64_stats_read(&p->tx_packets);
tx_bytes = p->tx_bytes; tx_bytes = u64_stats_read(&p->tx_bytes);
} while (u64_stats_fetch_retry_irq(&p->syncp, start)); } while (u64_stats_fetch_retry_irq(&p->syncp, start));
stats->rx_packets += rx_packets; stats->rx_packets += rx_packets;
...@@ -1870,9 +1870,9 @@ team_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) ...@@ -1870,9 +1870,9 @@ team_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
* rx_dropped, tx_dropped & rx_nohandler are u32, * rx_dropped, tx_dropped & rx_nohandler are u32,
* updated without syncp protection. * updated without syncp protection.
*/ */
rx_dropped += p->rx_dropped; rx_dropped += READ_ONCE(p->rx_dropped);
tx_dropped += p->tx_dropped; tx_dropped += READ_ONCE(p->tx_dropped);
rx_nohandler += p->rx_nohandler; rx_nohandler += READ_ONCE(p->rx_nohandler);
} }
stats->rx_dropped = rx_dropped; stats->rx_dropped = rx_dropped;
stats->tx_dropped = tx_dropped; stats->tx_dropped = tx_dropped;
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
#include <uapi/linux/if_team.h> #include <uapi/linux/if_team.h>
struct team_pcpu_stats { struct team_pcpu_stats {
u64 rx_packets; u64_stats_t rx_packets;
u64 rx_bytes; u64_stats_t rx_bytes;
u64 rx_multicast; u64_stats_t rx_multicast;
u64 tx_packets; u64_stats_t tx_packets;
u64 tx_bytes; u64_stats_t tx_bytes;
struct u64_stats_sync syncp; struct u64_stats_sync syncp;
u32 rx_dropped; u32 rx_dropped;
u32 tx_dropped; u32 tx_dropped;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment