aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2019-11-07 16:27:22 -0800
committerDavid S. Miller <davem@davemloft.net>2019-11-07 20:03:08 -0800
commitfd2f4737870eb866537fbbffa2b59414b9b0c0a2 (patch)
tree1a717aaeccccc9d8ff8f923dc9ac4f0d840655cd /include/linux/netdevice.h
parenttun: switch to u64_stats_t (diff)
downloadwireguard-linux-fd2f4737870eb866537fbbffa2b59414b9b0c0a2.tar.xz
wireguard-linux-fd2f4737870eb866537fbbffa2b59414b9b0c0a2.zip
net: use u64_stats_t in struct pcpu_lstats
In order to fix the data-race found by KCSAN, we can use the new u64_stats_t type and its accessors instead of plain u64 fields. This will still generate optimal code for both 32 and 64 bit platforms. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 461a36220cf4..f857f01234f7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2396,8 +2396,8 @@ struct pcpu_sw_netstats {
} __aligned(4 * sizeof(u64));
struct pcpu_lstats {
- u64 packets;
- u64 bytes;
+ u64_stats_t packets;
+ u64_stats_t bytes;
struct u64_stats_sync syncp;
} __aligned(2 * sizeof(u64));
@@ -2408,8 +2408,8 @@ static inline void dev_lstats_add(struct net_device *dev, unsigned int len)
struct pcpu_lstats *lstats = this_cpu_ptr(dev->lstats);
u64_stats_update_begin(&lstats->syncp);
- lstats->bytes += len;
- lstats->packets++;
+ u64_stats_add(&lstats->bytes, len);
+ u64_stats_inc(&lstats->packets);
u64_stats_update_end(&lstats->syncp);
}