Skip to contentSkip to conversation

net/mlx4_en: try to use high order pages for RX rings

PATCH Applied Eric Dumazet 3 participants 3 messages Mar 6, 2018 – Mar 7, 2018

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

PATCH 1/1 net/mlx4_en: try to use high order pages for RX rings

From: Eric Dumazet <[email protected]>

RX rings can fit most of the time in a contiguous piece of memory, so lets use kvzalloc_node/kvfree instead of vzalloc_node/vfree

Note that kvzalloc_node() automatically falls back to another node, there is no need to do the fallback ourselves.

---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c |   13 +++++--------

 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_rx.c +5 -8
index c2c6bd7578fdeeee42ded9b10c3993742a244b8f..05787efef492b1c0c6ce540ef73647fad91ce282 100644
@@ -291,13 +291,10 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
 
 	tmp = size * roundup_pow_of_two(MLX4_EN_MAX_RX_FRAGS *
 					sizeof(struct mlx4_en_rx_alloc));
-	ring->rx_info = vzalloc_node(tmp, node);
+	ring->rx_info = kvzalloc_node(tmp, GFP_KERNEL, node);
 	if (!ring->rx_info) {
-		ring->rx_info = vzalloc(tmp);
-		if (!ring->rx_info) {
-			err = -ENOMEM;
-			goto err_xdp_info;
-		}
+		err = -ENOMEM;
+		goto err_xdp_info;
 	}
 
 	en_dbg(DRV, priv, "Allocated rx_info ring at addr:%p size:%d\n",
@@ -318,7 +315,7 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
 	return 0;
 
 err_info:
-	vfree(ring->rx_info);
+	kvfree(ring->rx_info);
 	ring->rx_info = NULL;
 err_xdp_info:
 	xdp_rxq_info_unreg(&ring->xdp_rxq);
@@ -447,7 +444,7 @@ void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
 		bpf_prog_put(old_prog);
 	xdp_rxq_info_unreg(&ring->xdp_rxq);
 	mlx4_free_hwq_res(mdev->dev, &ring->wqres, size * stride + TXBB_SIZE);
-	vfree(ring->rx_info);
+	kvfree(ring->rx_info);
 	ring->rx_info = NULL;
 	kfree(ring);
 	*pring = NULL;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 45 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

RX rings can fit most of the time in a contiguous piece of memory, so lets use kvzalloc_node/kvfree instead of vzalloc_node/vfree

Note that kvzalloc_node() automatically falls back to another node, there is no need to do the fallback ourselves.

---
  drivers/net/ethernet/mellanox/mlx4/en_rx.c |   13 +++++--------
  1 file changed, 5 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_rx.c +4 -7
index c2c6bd7578fdeeee42ded9b10c3993742a244b8f..05787efef492b1c0c6ce540ef73647fad91ce282 100644
@@ -291,13 +291,10 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
 
  	tmp = size * roundup_pow_of_two(MLX4_EN_MAX_RX_FRAGS *
  					sizeof(struct mlx4_en_rx_alloc));
-	ring->rx_info = vzalloc_node(tmp, node);
+	ring->rx_info = kvzalloc_node(tmp, GFP_KERNEL, node);
  	if (!ring->rx_info) {
-		ring->rx_info = vzalloc(tmp);
-		if (!ring->rx_info) {
-			err = -ENOMEM;
-			goto err_xdp_info;
-		}
+		err = -ENOMEM;
+		goto err_xdp_info;
  	}
 
  	en_dbg(DRV, priv, "Allocated rx_info ring at addr:%p size:%d\n",
@@ -318,7 +315,7 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
  	return 0;
 
  err_info:
-	vfree(ring->rx_info);
+	kvfree(ring->rx_info);
  	ring->rx_info = NULL;
  err_xdp_info:
  	xdp_rxq_info_unreg(&ring->xdp_rxq);

drivers/net/ethernet/mellanox/mlx4/en_rx.c void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv, · line 450

Quoted 8 lines
drivers/net/ethernet/mellanox/mlx4/en_rx.c +1 -1
@@ -447,7 +444,7 @@ void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
  		bpf_prog_put(old_prog);
  	xdp_rxq_info_unreg(&ring->xdp_rxq);
  	mlx4_free_hwq_res(mdev->dev, &ring->wqres, size * stride + TXBB_SIZE);
-	vfree(ring->rx_info);
+	kvfree(ring->rx_info);
  	ring->rx_info = NULL;
  	kfree(ring);
  	*pring = NULL;

Thanks Eric.

maintainer Applied
#2 lore raw
In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Tue, 06 Mar 2018 11:12:53 -0800

Quoted 9 lines

From: Eric Dumazet <[email protected]>

RX rings can fit most of the time in a contiguous piece of memory, so lets use kvzalloc_node/kvfree instead of vzalloc_node/vfree

Note that kvzalloc_node() automatically falls back to another node, there is no need to do the fallback ourselves.

Applied.