net: qualcomm: rmnet: don't over-count statistics
authorAlex Elder <elder@linaro.org>
Fri, 11 Jun 2021 18:26:00 +0000 (13:26 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Jun 2021 12:42:44 +0000 (14:42 +0200)
commit0e185a7b285d2a84341a9d29ac935408ac5b662d
treed7793a0437a152c252095cddfa8223ad62d16f9f
parente3577776d6064c0633fdbc533019cb5c6092079d
net: qualcomm: rmnet: don't over-count statistics

[ Upstream commit 994c393bb6886d6d94d628475b274a8cb3fc67a4 ]

The purpose of the loop using u64_stats_fetch_*_irq() is to ensure
statistics on a given CPU are collected atomically. If one of the
statistics values gets updated within the begin/retry window, the
loop will run again.

Currently the statistics totals are updated inside that window.
This means that if the loop ever retries, the statistics for the
CPU will be counted more than once.

Fix this by taking a snapshot of a CPU's statistics inside the
protected window, and then updating the counters with the snapshot
values after exiting the loop.

(Also add a newline at the end of this file...)

Fixes: 192c4b5d48f2a ("net: qualcomm: rmnet: Add support for 64 bit stats")
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c