aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/sfc/ethtool.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2011-09-02 18:23:00 -0400
committerBen Hutchings <bhutchings@solarflare.com>2012-01-26 19:10:45 -0500
commit1cb345220f135dcca24f01cc04cbb97a8242d419 (patch)
tree059ec907cd50bd10114bd942d0ffbfa7fd080aa2 /drivers/net/ethernet/sfc/ethtool.c
parent788ec41cc843f12e8d0eba5f2b37af18b76654a5 (diff)
sfc: Hold efx_nic::stats_lock while reading efx_nic::mac_stats
efx_nic::stats_lock is used to serialise stats updates, but each reader was dropping it before it finished reading efx_nic::mac_stats. If there were concurrent stats reads using procfs, or one using procfs and one using ethtool, an update could race with a read. On a 32-bit system, the reader could see word-tearing of 64-bit stats (32 bits of the old value and 32 bits of the new). Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/ethernet/sfc/ethtool.c')
-rw-r--r--drivers/net/ethernet/sfc/ethtool.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
index 52c9ee4c8aa3..55a25b14d304 100644
--- a/drivers/net/ethernet/sfc/ethtool.c
+++ b/drivers/net/ethernet/sfc/ethtool.c
@@ -489,13 +489,14 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
489 const struct efx_ethtool_stat *stat; 489 const struct efx_ethtool_stat *stat;
490 struct efx_channel *channel; 490 struct efx_channel *channel;
491 struct efx_tx_queue *tx_queue; 491 struct efx_tx_queue *tx_queue;
492 struct rtnl_link_stats64 temp;
493 int i; 492 int i;
494 493
495 EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS); 494 EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS);
496 495
496 spin_lock_bh(&efx->stats_lock);
497
497 /* Update MAC and NIC statistics */ 498 /* Update MAC and NIC statistics */
498 dev_get_stats(net_dev, &temp); 499 efx->type->update_stats(efx);
499 500
500 /* Fill detailed statistics buffer */ 501 /* Fill detailed statistics buffer */
501 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) { 502 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) {
@@ -525,6 +526,8 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
525 break; 526 break;
526 } 527 }
527 } 528 }
529
530 spin_unlock_bh(&efx->stats_lock);
528} 531}
529 532
530static void efx_ethtool_self_test(struct net_device *net_dev, 533static void efx_ethtool_self_test(struct net_device *net_dev,