linux/drivers/net/ethernet
Martin KaFai Lau 1510d72863 net/mlx5e: Fix race in mlx5e_sw_stats and mlx5e_vport_stats
We have observed a sudden spike in rx/tx_packets and rx/tx_bytes
reported under /proc/net/dev.  There is a race in mlx5e_update_stats()
and some of the get-stats functions (the one that we hit is the
mlx5e_get_stats() which is called by ndo_get_stats64()).

In particular, the very first thing mlx5e_update_sw_counters()
does is 'memset(s, 0, sizeof(*s))'.  For example, if mlx5e_get_stats()
is unlucky at one point, rx_bytes and rx_packets could be 0.  One second
later, a normal (and much bigger than 0) value will be reported.

This patch is to use a 'struct mlx5e_sw_stats temp' to avoid
a direct memset zero on priv->stats.sw.

mlx5e_update_vport_counters() has a similar race.  Hence, addressed
together.  However, memset zero is removed instead because
it is not needed.

I am lucky enough to catch this 0-reset in rx multicast:
eth0: 41457665   76804   70    0    0    70          0     47085 15586634   87502    3    0    0     0       3          0
eth0: 41459860   76815   70    0    0    70          0     47094 15588376   87516    3    0    0     0       3          0
eth0: 41460577   76822   70    0    0    70          0         0 15589083   87521    3    0    0     0       3          0
eth0: 41463293   76838   70    0    0    70          0     47108 15595872   87538    3    0    0     0       3          0
eth0: 41463379   76839   70    0    0    70          0     47116 15596138   87539    3    0    0     0       3          0

v2: Remove memset zero from mlx5e_update_vport_counters()
v1: Use temp and memcpy

Fixes: 9218b44dcc ("net/mlx5e: Statistics handling refactoring")
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Suggested-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-04-24 12:15:08 -04:00
..
3com drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
8390 Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
adaptec net: adaptec: starfire: add checks for dma mapping errors 2017-01-29 19:04:11 -05:00
adi scripts/spelling.txt: add "overwritting" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
aeroflex aeroflex/greth: use napi_complete_done() 2017-02-05 16:11:57 -05:00
agere drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
alacritech net: make ndo_get_stats64 a void function 2017-01-08 17:51:44 -05:00
allwinner
alteon Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
altera drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
amazon net: ena: remove superfluous check in ena_remove() 2017-02-20 10:22:59 -05:00
amd amd-xgbe: Fix the ECC-related bit position definitions 2017-03-22 19:39:58 -07:00
apm drivers: net: xgene: Fix crash on DT systems 2017-03-02 12:47:23 -08:00
apple
aquantia net:ethernet:aquantia: Reset is_gso flag when EOP reached. 2017-03-24 12:32:19 -07:00
arc drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
atheros atl1e: add GRO support 2017-02-03 11:13:17 -05:00
aurora
broadcom bnx2x: fix spelling mistake in macros HW_INTERRUT_ASSERT_SET_* 2017-04-04 10:04:49 -07:00
brocade bna: avoid writing uninitialized data into hw registers 2017-03-24 12:49:12 -07:00
cadence lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
calxeda drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
cavium net: thunderx: Fix set_max_bgx_per_node for 81xx rgx 2017-04-17 13:03:48 -04:00
chelsio Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-03-04 17:31:39 -08:00
cirrus ep93xx_eth: add GRO support 2017-02-05 16:11:57 -05:00
cisco enic: add vxlan offload on tx path 2017-02-09 17:24:29 -05:00
davicom
dec drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
dlink net: dlink: sundance: use new api ethtool_{get|set}_link_ksettings 2017-01-02 16:59:10 -05:00
emulex be2net: Fix endian issue in logical link config command 2017-03-30 15:57:33 -07:00
ezchip ezchip: nps_enet: check if napi has been completed 2017-03-29 14:28:16 -07:00
faraday net/faraday: Explicitly include linux/of.h and linux/property.h 2017-04-01 12:14:00 -07:00
freescale dpaa_eth: implement ioctl() for PHY-related ops 2017-02-20 22:21:23 -05:00
fujitsu Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
hisilicon net: hns: Add ACPI support to check SFP present 2017-04-01 12:10:58 -07:00
hp
i825xx
ibm ibmvnic: Free tx/rx scrq pointer array when releasing sub-crqs 2017-03-16 21:25:43 -07:00
intel i40e: Do not enable NAPI on q_vectors that have no rings 2017-03-24 19:28:55 -07:00
marvell net: mvpp2: enable building on 64-bit platforms 2017-02-21 13:16:17 -05:00
mediatek net: ethernet: mediatek: fix inconsistency of port number carried in TXD 2017-04-17 13:33:58 -04:00
mellanox net/mlx5e: Fix race in mlx5e_sw_stats and mlx5e_vport_stats 2017-04-24 12:15:08 -04:00
micrel scripts/spelling.txt: add "overrided" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
microchip net: microchip: encx24j600: use new api ethtool_{get|set}_link_ksettings 2017-02-12 22:32:17 -05:00
moxa net: moxa: fix TX overrun memory leak 2017-03-28 18:02:05 -07:00
myricom net: myricom: myri10ge: use new api ethtool_{get|set}_link_ksettings 2017-02-12 22:32:17 -05:00
natsemi net: natsemi: ns83820: use new api ethtool_{get|set}_link_ksettings 2017-02-12 22:32:17 -05:00
neterion net: s2io: fix typo argumnet argument 2017-02-26 11:57:58 -05:00
netronome nfp: fix potential use after free on xdp prog 2017-04-05 18:46:40 -07:00
nuvoton net: nuvoton: w90p910: use new api ethtool_{get|set}_link_ksettings 2017-02-12 22:32:17 -05:00
nvidia forcedeth: Remove return from a void function 2017-02-23 10:55:07 -05:00
nxp drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
oki-semi net: oki-semi: pch_gbe: use new api ethtool_{get|set}_link_ksettings 2017-02-17 12:00:14 -05:00
packetengines net: hamachi: use new api ethtool_{get|set}_link_ksettings 2017-02-17 14:06:41 -05:00
pasemi drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
qlogic qed: Fix issue in populating the PFC config paramters. 2017-04-20 16:29:40 -04:00
qualcomm net: qualcomm: qca: use new api ethtool_{get|set}_link_ksettings 2017-02-20 22:19:08 -05:00
rdc
realtek 8139cp: use napi_complete_done() 2017-02-05 16:11:57 -05:00
renesas sh_eth: unmap DMA buffers when freeing rings 2017-04-18 22:04:32 -04:00
rocker rocker: fix Wmaybe-uninitialized false-positive 2017-03-28 21:42:32 -07:00
samsung drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
seeq drivers: net: ethernet: remove incorrect __exit markups 2017-03-02 14:33:49 -08:00
sfc sfc: limit the number of receive queues 2017-04-17 11:01:19 -04:00
sgi drivers: net: ethernet: remove incorrect __exit markups 2017-03-02 14:33:49 -08:00
silan
sis scripts/spelling.txt: add "comsume(r)" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
smsc net: Revert ksettings conversions. 2017-03-08 22:17:10 -08:00
stmicro net: stmmac: unify registers dumps methods 2017-02-24 11:42:33 -05:00
sun net: Revert ksettings conversions. 2017-03-08 22:17:10 -08:00
tehuti drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
ti net: ethernet: ti: cpsw: fix race condition during open() 2017-04-04 10:33:33 -07:00
tile drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
toshiba net: Revert ksettings conversions. 2017-03-08 22:17:10 -08:00
tundra drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
via drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
wiznet drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
xilinx Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-02-16 19:34:01 -05:00
xircom Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
xscale
dnet.c drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
dnet.h
ec_bhf.c net: make ndo_get_stats64 a void function 2017-01-08 17:51:44 -05:00
ethoc.c net: ethoc: Use eth_hw_addr_random() 2017-02-17 12:42:24 -05:00
fealnx.c net: fealnx: use new api ethtool_{get|set}_link_ksettings 2017-01-02 16:59:10 -05:00
jme.c net: jme: use new api ethtool_{get|set}_link_ksettings 2017-01-17 11:44:27 -05:00
jme.h net: jme: use new api ethtool_{get|set}_link_ksettings 2017-01-17 11:44:27 -05:00
Kconfig net: ethernet: aquantia: Integrate AQtion 2.5/5 GB NIC driver 2017-01-24 15:03:41 -05:00
korina.c drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
lantiq_etop.c drivers: net: generalize napi_complete_done() 2017-01-30 15:10:42 -05:00
Makefile net: ethernet: aquantia: Integrate AQtion 2.5/5 GB NIC driver 2017-01-24 15:03:41 -05:00
netx-eth.c