Skip to contentSkip to conversation

net/mlx4_en: remove fallback after kzalloc_node()

PATCH Applied Eric Dumazet 2 participants 3 messages Dec 13, 2018 – Dec 17, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx4_en: remove fallback after kzalloc_node()

kzalloc_node(..., GFP_KERNEL, node) will attempt to allocate memory as close as possible to the node.

There is no need to fallback to kzalloc() if this has failed.

---
 drivers/net/ethernet/mellanox/mlx4/en_cq.c | 7 ++-----
 drivers/net/ethernet/mellanox/mlx4/en_rx.c | 7 ++-----
 drivers/net/ethernet/mellanox/mlx4/en_tx.c | 7 ++-----
 3 files changed, 6 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_cq.c +2 -5
index 062a88fcc5d6a82097da7c27484513a01ebe0d88..74d466796b7c726a11e8f885a59dba20df479c2b 100644
@@ -54,11 +54,8 @@ int mlx4_en_create_cq(struct mlx4_en_priv *priv,
 
 	cq = kzalloc_node(sizeof(*cq), GFP_KERNEL, node);
 	if (!cq) {
-		cq = kzalloc(sizeof(*cq), GFP_KERNEL);
-		if (!cq) {
-			en_err(priv, "Failed to allocate CQ structure\n");
-			return -ENOMEM;
-		}
+		en_err(priv, "Failed to allocate CQ structure\n");
+		return -ENOMEM;
 	}
 
 	cq->size = entries;
drivers/net/ethernet/mellanox/mlx4/en_rx.c +2 -5
index fd09ba98c0a6785eb6722284dc98975f577dac53..9a0881cb7f51d54fb5dff8f9ed9884cd5f3b867f 100644
@@ -271,11 +271,8 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
 
 	ring = kzalloc_node(sizeof(*ring), GFP_KERNEL, node);
 	if (!ring) {
-		ring = kzalloc(sizeof(*ring), GFP_KERNEL);
-		if (!ring) {
-			en_err(priv, "Failed to allocate RX ring structure\n");
-			return -ENOMEM;
-		}
+		en_err(priv, "Failed to allocate RX ring structure\n");
+		return -ENOMEM;
 	}
 
 	ring->prod = 0;
drivers/net/ethernet/mellanox/mlx4/en_tx.c +2 -5
index 6f5153afcab4dfc331c099da854c54f1b9500887..2cbd2bd7c67ceae405ff2fa8114925a3e984e17d 100644
@@ -57,11 +57,8 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv,
 
 	ring = kzalloc_node(sizeof(*ring), GFP_KERNEL, node);
 	if (!ring) {
-		ring = kzalloc(sizeof(*ring), GFP_KERNEL);
-		if (!ring) {
-			en_err(priv, "Failed allocating TX ring\n");
-			return -ENOMEM;
-		}
+		en_err(priv, "Failed allocating TX ring\n");
+		return -ENOMEM;
 	}
 
 	ring->size = size;
Signature · 1 line
2.20.0.rc2.403.gdbc3b29805-goog
maintainer
#1 lore raw

From: Eric Dumazet <[email protected]>
Date: Thu, 13 Dec 2018 03:03:37 -0800

Quoted 7 lines

kzalloc_node(..., GFP_KERNEL, node) will attempt to allocate memory as close as possible to the node.

There is no need to fallback to kzalloc() if this has failed.

Tariq, please take a look and review this patch.

Thank you.

maintainer Applied
#2 lore raw
In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Thu, 13 Dec 2018 03:03:37 -0800

Quoted 7 lines

kzalloc_node(..., GFP_KERNEL, node) will attempt to allocate memory as close as possible to the node.

There is no need to fallback to kzalloc() if this has failed.

I think I gave Tariq long enough time to review this if he wanted to.

Applied, thanks Eric.