Skip to contentSkip to conversation

net/mlx5: Node-aware allocation for mlx5_buf_list

PATCH In review Adam Li 2 participants 3 messages Sep 6, 2024 – Oct 12, 2024 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

Adam Li

author
#0 lore raw

PATCH 1/1 net/mlx5: Node-aware allocation for mlx5_buf_list

Allocation for mlx5_frag_buf.frags[i].buf is node-aware. Make mlx5_frag_buf.frags allocation node-aware too.

---
 drivers/net/ethernet/mellanox/mlx5/core/alloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/alloc.c +2 -2
index 6aca004e88cd..fda17b41ff17 100644
@@ -79,8 +79,8 @@ int mlx5_frag_buf_alloc_node(struct mlx5_core_dev *dev, int size,
 	buf->size = size;
 	buf->npages = DIV_ROUND_UP(size, PAGE_SIZE);
 	buf->page_shift = PAGE_SHIFT;
-	buf->frags = kcalloc(buf->npages, sizeof(struct mlx5_buf_list),
-			     GFP_KERNEL);
+	buf->frags = kcalloc_node(buf->npages, sizeof(struct mlx5_buf_list),
+				  GFP_KERNEL, node);
 	if (!buf->frags)
 		goto err_out;
 
Signature · 1 line
2.25.1

A message that is not in the archive (sent off-list or not yet received): ZuCv8VyJqoChZLIx@x130

author
#3 lore raw

Hi Saeed,

Very sorry for the slow reply.

Quoted 7 lines · Saeed Mahameed
Quoted 3 lines · Adam Li

Allocation for mlx5_frag_buf.frags[i].buf is node-aware. Make mlx5_frag_buf.frags allocation node-aware too.

Why ? buf is accessed by the device but "frags" only accessed by CPU.

Yes, this patch hopes to minimize CPU cross node memory access. I observed 'frags' is accessed on RX path from mlx5e_alloc_rx_mpwqe().

Quoted 21 lines
Quoted 21 lines

---
drivers/net/ethernet/mellanox/mlx5/core/alloc.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/alloc.c +2 -2
index 6aca004e88cd..fda17b41ff17 100644
@@ -79,8 +79,8 @@ int mlx5_frag_buf_alloc_node(struct mlx5_core_dev *dev, int size,
     buf->size = size;
     buf->npages = DIV_ROUND_UP(size, PAGE_SIZE);
     buf->page_shift = PAGE_SHIFT;
-    buf->frags = kcalloc(buf->npages, sizeof(struct mlx5_buf_list),
-                 GFP_KERNEL);
+    buf->frags = kcalloc_node(buf->npages, sizeof(struct mlx5_buf_list),
+                  GFP_KERNEL, node);
     if (!buf->frags)
         goto err_out;
 
Quoted 4 lines
Quoted 4 lines

--
2.25.1

Thanks,
-adam