Commit 9962acef authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski
Browse files

net: adopt u64_stats_t in struct pcpu_sw_netstats



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 eeb15885
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -523,8 +523,8 @@ static void count_tx(struct net_device *dev, int ret, int len)
		struct pcpu_sw_netstats *stats = this_cpu_ptr(dev->tstats);

		u64_stats_update_begin(&stats->syncp);
		stats->tx_packets++;
		stats->tx_bytes += len;
		u64_stats_inc(&stats->tx_packets);
		u64_stats_add(&stats->tx_bytes, len);
		u64_stats_update_end(&stats->syncp);
	}
}
@@ -825,8 +825,8 @@ static void count_rx(struct net_device *dev, int len)
	struct pcpu_sw_netstats *stats = this_cpu_ptr(dev->tstats);

	u64_stats_update_begin(&stats->syncp);
	stats->rx_packets++;
	stats->rx_bytes += len;
	u64_stats_inc(&stats->rx_packets);
	u64_stats_add(&stats->rx_bytes, len);
	u64_stats_update_end(&stats->syncp);
}

+4 −4
Original line number Diff line number Diff line
@@ -337,8 +337,8 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
		skb->protocol = eth_type_trans (skb, dev->net);

	flags = u64_stats_update_begin_irqsave(&stats64->syncp);
	stats64->rx_packets++;
	stats64->rx_bytes += skb->len;
	u64_stats_inc(&stats64->rx_packets);
	u64_stats_add(&stats64->rx_bytes, skb->len);
	u64_stats_update_end_irqrestore(&stats64->syncp, flags);

	netif_dbg(dev, rx_status, dev->net, "< rx, len %zu, type 0x%x\n",
@@ -1258,8 +1258,8 @@ static void tx_complete (struct urb *urb)
		unsigned long flags;

		flags = u64_stats_update_begin_irqsave(&stats64->syncp);
		stats64->tx_packets += entry->packets;
		stats64->tx_bytes += entry->length;
		u64_stats_add(&stats64->tx_packets, entry->packets);
		u64_stats_add(&stats64->tx_bytes, entry->length);
		u64_stats_update_end_irqrestore(&stats64->syncp, flags);
	} else {
		dev->net->stats.tx_errors++;
+4 −4
Original line number Diff line number Diff line
@@ -2385,15 +2385,15 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
		vxlan_snoop(dev, &loopback, eth_hdr(skb)->h_source, 0, vni);

	u64_stats_update_begin(&tx_stats->syncp);
	tx_stats->tx_packets++;
	tx_stats->tx_bytes += len;
	u64_stats_inc(&tx_stats->tx_packets);
	u64_stats_add(&tx_stats->tx_bytes, len);
	u64_stats_update_end(&tx_stats->syncp);
	vxlan_vnifilter_count(src_vxlan, vni, NULL, VXLAN_VNI_STATS_TX, len);

	if (__netif_rx(skb) == NET_RX_SUCCESS) {
		u64_stats_update_begin(&rx_stats->syncp);
		rx_stats->rx_packets++;
		rx_stats->rx_bytes += len;
		u64_stats_inc(&rx_stats->rx_packets);
		u64_stats_add(&rx_stats->rx_bytes, len);
		u64_stats_update_end(&rx_stats->syncp);
		vxlan_vnifilter_count(dst_vxlan, vni, NULL, VXLAN_VNI_STATS_RX,
				      len);
+8 −8
Original line number Diff line number Diff line
@@ -2636,10 +2636,10 @@ struct packet_offload {

/* often modified stats are per-CPU, other are shared (netdev->stats) */
struct pcpu_sw_netstats {
	u64     rx_packets;
	u64     rx_bytes;
	u64     tx_packets;
	u64     tx_bytes;
	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;
} __aligned(4 * sizeof(u64));

@@ -2656,8 +2656,8 @@ static inline void dev_sw_netstats_rx_add(struct net_device *dev, unsigned int l
	struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);

	u64_stats_update_begin(&tstats->syncp);
	tstats->rx_bytes += len;
	tstats->rx_packets++;
	u64_stats_add(&tstats->rx_bytes, len);
	u64_stats_inc(&tstats->rx_packets);
	u64_stats_update_end(&tstats->syncp);
}

@@ -2668,8 +2668,8 @@ static inline void dev_sw_netstats_tx_add(struct net_device *dev,
	struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);

	u64_stats_update_begin(&tstats->syncp);
	tstats->tx_bytes += len;
	tstats->tx_packets += packets;
	u64_stats_add(&tstats->tx_bytes, len);
	u64_stats_add(&tstats->tx_packets, packets);
	u64_stats_update_end(&tstats->syncp);
}

+2 −2
Original line number Diff line number Diff line
@@ -456,8 +456,8 @@ static inline void iptunnel_xmit_stats(struct net_device *dev, int pkt_len)
		struct pcpu_sw_netstats *tstats = get_cpu_ptr(dev->tstats);

		u64_stats_update_begin(&tstats->syncp);
		tstats->tx_bytes += pkt_len;
		tstats->tx_packets++;
		u64_stats_add(&tstats->tx_bytes, pkt_len);
		u64_stats_inc(&tstats->tx_packets);
		u64_stats_update_end(&tstats->syncp);
		put_cpu_ptr(tstats);
	} else {
Loading