diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2015-05-08 13:44:13 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2015-05-27 21:35:20 -0400 |
commit | f36963c9d3f6f415732710da3acdd8608a9fa0e5 (patch) | |
tree | 1a7bdf324a50bc75efe6c57c2525ccffd9c385f4 /drivers/net/ethernet/mellanox | |
parent | 37815bf866ab6722a47550f8d25ad3f1a16a680c (diff) |
cpumask_set_cpu_local_first => cpumask_local_spread, lament
da91309e0a7e (cpumask: Utility function to set n'th cpu...) created a
genuinely weird function. I never saw it before, it went through DaveM.
(He only does this to make us other maintainers feel better about our own
mistakes.)
cpumask_set_cpu_local_first's purpose is say "I need to spread things
across N online cpus, choose the ones on this numa node first"; you call
it in a loop.
It can fail. One of the two callers ignores this, the other aborts and
fails the device open.
It can fail in two ways: allocating the off-stack cpumask, or through a
convoluted codepath which AFAICT can only occur if cpu_online_mask
changes. Which shouldn't happen, because if cpu_online_mask can change
while you call this, it could return a now-offline cpu anyway.
It contains a nonsensical test "!cpumask_of_node(numa_node)". This was
drawn to my attention by Geert, who said this causes a warning on Sparc.
It sets a single bit in a cpumask instead of returning a cpu number,
because that's what the callers want.
It could be made more efficient by passing the previous cpu rather than
an index, but that would be more invasive to the callers.
Fixes: da91309e0a7e8966d916a74cce42ed170fde06bf
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (then rebased)
Tested-by: Amir Vadai <amirv@mellanox.com>
Acked-by: Amir Vadai <amirv@mellanox.com>
Acked-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 10 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_tx.c | 6 |
2 files changed, 6 insertions, 10 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 32f5ec737472..cf467a9f6cc7 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
@@ -1501,17 +1501,13 @@ static int mlx4_en_init_affinity_hint(struct mlx4_en_priv *priv, int ring_idx) | |||
1501 | { | 1501 | { |
1502 | struct mlx4_en_rx_ring *ring = priv->rx_ring[ring_idx]; | 1502 | struct mlx4_en_rx_ring *ring = priv->rx_ring[ring_idx]; |
1503 | int numa_node = priv->mdev->dev->numa_node; | 1503 | int numa_node = priv->mdev->dev->numa_node; |
1504 | int ret = 0; | ||
1505 | 1504 | ||
1506 | if (!zalloc_cpumask_var(&ring->affinity_mask, GFP_KERNEL)) | 1505 | if (!zalloc_cpumask_var(&ring->affinity_mask, GFP_KERNEL)) |
1507 | return -ENOMEM; | 1506 | return -ENOMEM; |
1508 | 1507 | ||
1509 | ret = cpumask_set_cpu_local_first(ring_idx, numa_node, | 1508 | cpumask_set_cpu(cpumask_local_spread(ring_idx, numa_node), |
1510 | ring->affinity_mask); | 1509 | ring->affinity_mask); |
1511 | if (ret) | 1510 | return 0; |
1512 | free_cpumask_var(ring->affinity_mask); | ||
1513 | |||
1514 | return ret; | ||
1515 | } | 1511 | } |
1516 | 1512 | ||
1517 | static void mlx4_en_free_affinity_hint(struct mlx4_en_priv *priv, int ring_idx) | 1513 | static void mlx4_en_free_affinity_hint(struct mlx4_en_priv *priv, int ring_idx) |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index f7bf312fb443..7bed3a88579f 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c | |||
@@ -144,9 +144,9 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, | |||
144 | ring->queue_index = queue_index; | 144 | ring->queue_index = queue_index; |
145 | 145 | ||
146 | if (queue_index < priv->num_tx_rings_p_up) | 146 | if (queue_index < priv->num_tx_rings_p_up) |
147 | cpumask_set_cpu_local_first(queue_index, | 147 | cpumask_set_cpu(cpumask_local_spread(queue_index, |
148 | priv->mdev->dev->numa_node, | 148 | priv->mdev->dev->numa_node), |
149 | &ring->affinity_mask); | 149 | &ring->affinity_mask); |
150 | 150 | ||
151 | *pring = ring; | 151 | *pring = ring; |
152 | return 0; | 152 | return 0; |