]> git.baikalelectronics.ru Git - kernel.git/commit
net: add atomic_long_t to net_device_stats fields
authorEric Dumazet <edumazet@google.com>
Tue, 15 Nov 2022 08:53:55 +0000 (08:53 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:37 +0000 (11:41 +0100)
commit7af61714862943487bcc28321f9fefef07389ce7
tree55e426b740a30de2b7844be880fd7d1045b810e0
parenta2b3cd3cd904b1e179f7a3247782e42e0a11d5ef
net: add atomic_long_t to net_device_stats fields

[ Upstream commit e8677964572b7cf17be7e79abe141e1ed061a681 ]

Long standing KCSAN issues are caused by data-race around
some dev->stats changes.

Most performance critical paths already use per-cpu
variables, or per-queue ones.

It is reasonable (and more correct) to use atomic operations
for the slow paths.

This patch adds an union for each field of net_device_stats,
so that we can convert paths that are not yet protected
by a spinlock or a mutex.

netdev_stats_to_stats64() no longer has an #if BITS_PER_LONG==64

Note that the memcpy() we were using on 64bit arches
had no provision to avoid load-tearing,
while atomic_long_read() is providing the needed protection
at no cost.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/netdevice.h
include/net/dst.h
net/core/dev.c