Commit 9ed17db1 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net/mlx4_en: get rid of ret_stats

mlx4 uses a private struct net_device_stats in a vain attempt
to avoid races.

This is buggy because multiple cpus could call mlx4_en_get_stats()
at the same time, so ret_stats can not guarantee stable results.

To fix this, we need to switch to ndo_get_stats64() as this
method provides per-thread storage.

This allows to reduce mlx4_en_priv bloat.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Cc: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 45acbac6
...@@ -1296,15 +1296,16 @@ static void mlx4_en_tx_timeout(struct net_device *dev) ...@@ -1296,15 +1296,16 @@ static void mlx4_en_tx_timeout(struct net_device *dev)
} }
static struct net_device_stats *mlx4_en_get_stats(struct net_device *dev) static struct rtnl_link_stats64 *
mlx4_en_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{ {
struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_priv *priv = netdev_priv(dev);
spin_lock_bh(&priv->stats_lock); spin_lock_bh(&priv->stats_lock);
memcpy(&priv->ret_stats, &priv->stats, sizeof(priv->stats)); netdev_stats_to_stats64(stats, &priv->stats);
spin_unlock_bh(&priv->stats_lock); spin_unlock_bh(&priv->stats_lock);
return &priv->ret_stats; return stats;
} }
static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv) static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv)
...@@ -2487,7 +2488,7 @@ static const struct net_device_ops mlx4_netdev_ops = { ...@@ -2487,7 +2488,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
.ndo_stop = mlx4_en_close, .ndo_stop = mlx4_en_close,
.ndo_start_xmit = mlx4_en_xmit, .ndo_start_xmit = mlx4_en_xmit,
.ndo_select_queue = mlx4_en_select_queue, .ndo_select_queue = mlx4_en_select_queue,
.ndo_get_stats = mlx4_en_get_stats, .ndo_get_stats64 = mlx4_en_get_stats64,
.ndo_set_rx_mode = mlx4_en_set_rx_mode, .ndo_set_rx_mode = mlx4_en_set_rx_mode,
.ndo_set_mac_address = mlx4_en_set_mac, .ndo_set_mac_address = mlx4_en_set_mac,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
...@@ -2519,7 +2520,7 @@ static const struct net_device_ops mlx4_netdev_ops_master = { ...@@ -2519,7 +2520,7 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
.ndo_stop = mlx4_en_close, .ndo_stop = mlx4_en_close,
.ndo_start_xmit = mlx4_en_xmit, .ndo_start_xmit = mlx4_en_xmit,
.ndo_select_queue = mlx4_en_select_queue, .ndo_select_queue = mlx4_en_select_queue,
.ndo_get_stats = mlx4_en_get_stats, .ndo_get_stats64 = mlx4_en_get_stats64,
.ndo_set_rx_mode = mlx4_en_set_rx_mode, .ndo_set_rx_mode = mlx4_en_set_rx_mode,
.ndo_set_mac_address = mlx4_en_set_mac, .ndo_set_mac_address = mlx4_en_set_mac,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
......
...@@ -484,7 +484,6 @@ struct mlx4_en_priv { ...@@ -484,7 +484,6 @@ struct mlx4_en_priv {
struct net_device *dev; struct net_device *dev;
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
struct net_device_stats stats; struct net_device_stats stats;
struct net_device_stats ret_stats;
struct mlx4_en_port_state port_state; struct mlx4_en_port_state port_state;
spinlock_t stats_lock; spinlock_t stats_lock;
struct ethtool_flow_id ethtool_rules[MAX_NUM_OF_FS_RULES]; struct ethtool_flow_id ethtool_rules[MAX_NUM_OF_FS_RULES];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment