🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Jakub Kicinski Wed, 18 Nov 2026 02:39
[PATCH net-next 3/6] eth: bnxt_en: allocate per-queue SW state on the queue's NUMA node
#18264
Author: Jakub Kicinski
Date: Wed, 18 Nov 2026 02:39
306 lines
17680 bytes
Allocate the SW rings, agg bitmap, TPA state, completion ring
page arrays, completion sub-ring structs, SW stats and the SW USO
header buffer on the NUMA node of the CPU which will service the queue.
This lowers the cost of cache misses for NAPI fast path (and xmit, for Tx).

Previous change already allocated the page pools on the right node.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 87 ++++++++++++++---------
 1 file changed, 52 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 8e8ee02ca8d9..7c694d8e99f5 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3765,7 +3765,8 @@ static void bnxt_free_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem)
 	}
 }
 
-static int bnxt_alloc_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem)
+static int bnxt_alloc_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem,
+			   int nid)
 {
 	struct pci_dev *pdev = bp->pdev;
 	u64 valid_bit = 0;
@@ -3810,8 +3811,9 @@ static int bnxt_alloc_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem)
 		}
 	}
 
+	/* Only the SW ring follows @nid, DMA memory is on the device's node */
 	if (rmem->vmem_size) {
-		*rmem->vmem = vzalloc(rmem->vmem_size);
+		*rmem->vmem = vzalloc_node(rmem->vmem_size, nid);
 		if (!(*rmem->vmem))
 			return -ENOMEM;
 	}
@@ -3862,25 +3864,27 @@ static void bnxt_free_tpa_info(struct bnxt *bp)
 }
 
 static int bnxt_alloc_one_tpa_info(struct bnxt *bp,
-				   struct bnxt_rx_ring_info *rxr)
+				   struct bnxt_rx_ring_info *rxr, int nid)
 {
 	struct rx_agg_cmp *agg;
 	int i;
 
-	rxr->rx_tpa = kzalloc_objs(struct bnxt_tpa_info,
-				   bp->max_tpa_roundup_size);
+	rxr->rx_tpa = kcalloc_node(bp->max_tpa_roundup_size,
+				   sizeof(*rxr->rx_tpa), GFP_KERNEL, nid);
 	if (!rxr->rx_tpa)
 		return -ENOMEM;
 
 	if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))
 		return 0;
 	for (i = 0; i < bp->max_tpa_roundup_size; i++) {
-		agg = kzalloc_objs(*agg, MAX_SKB_FRAGS);
+		agg = kcalloc_node(MAX_SKB_FRAGS, sizeof(*agg),
+				   GFP_KERNEL, nid);
 		if (!agg)
 			return -ENOMEM;
 		rxr->rx_tpa[i].agg_arr = agg;
 	}
-	rxr->rx_tpa_idx_map = kzalloc_obj(*rxr->rx_tpa_idx_map);
+	rxr->rx_tpa_idx_map = kzalloc_node(sizeof(*rxr->rx_tpa_idx_map),
+					   GFP_KERNEL, nid);
 	if (!rxr->rx_tpa_idx_map)
 		return -ENOMEM;
 
@@ -3907,8 +3911,10 @@ static int bnxt_alloc_tpa_info(struct bnxt *bp)
 
 	for (i = 0; i < bp->rx_nr_rings; i++) {
 		struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
+		int nid;
 
-		rc = bnxt_alloc_one_tpa_info(bp, rxr);
+		nid = bnxt_cp_num_to_node(bp, i);
+		rc = bnxt_alloc_one_tpa_info(bp, rxr, nid);
 		if (rc)
 			return rc;
 	}
@@ -4020,13 +4026,14 @@ static void bnxt_enable_rx_page_pool(struct bnxt_rx_ring_info *rxr)
 	page_pool_enable_direct_recycling(rxr->page_pool, &rxr->bnapi->napi);
 }
 
-static int bnxt_alloc_rx_agg_bmap(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
+static int bnxt_alloc_rx_agg_bmap(struct bnxt *bp,
+				  struct bnxt_rx_ring_info *rxr, int nid)
 {
 	u16 mem_size;
 
 	rxr->rx_agg_bmap_size = bp->rx_agg_ring_mask + 1;
 	mem_size = rxr->rx_agg_bmap_size / 8;
-	rxr->rx_agg_bmap = kzalloc(mem_size, GFP_KERNEL);
+	rxr->rx_agg_bmap = kzalloc_node(mem_size, GFP_KERNEL, nid);
 	if (!rxr->rx_agg_bmap)
 		return -ENOMEM;
 
@@ -4070,19 +4077,19 @@ static int bnxt_alloc_rx_rings(struct bnxt *bp)
 			return rc;
 		}
 
-		rc = bnxt_alloc_ring(bp, &ring->ring_mem);
+		rc = bnxt_alloc_ring(bp, &ring->ring_mem, cpu_node);
 		if (rc)
 			return rc;
 
 		ring->grp_idx = i;
 		if (agg_rings) {
 			ring = &rxr->rx_agg_ring_struct;
-			rc = bnxt_alloc_ring(bp, &ring->ring_mem);
+			rc = bnxt_alloc_ring(bp, &ring->ring_mem, cpu_node);
 			if (rc)
 				return rc;
 
 			ring->grp_idx = i;
-			rc = bnxt_alloc_rx_agg_bmap(bp, rxr);
+			rc = bnxt_alloc_rx_agg_bmap(bp, rxr, cpu_node);
 			if (rc)
 				return rc;
 		}
@@ -4107,9 +4114,9 @@ static void bnxt_free_tx_inline_buf(struct bnxt_tx_ring_info *txr,
 
 static int bnxt_alloc_tx_inline_buf(struct bnxt_tx_ring_info *txr,
 				    struct pci_dev *pdev,
-				    unsigned int size)
+				    unsigned int size, int nid)
 {
-	txr->tx_inline_buf = kmalloc(size, GFP_KERNEL);
+	txr->tx_inline_buf = kmalloc_node(size, GFP_KERNEL, nid);
 	if (!txr->tx_inline_buf)
 		return -ENOMEM;
 
@@ -4183,11 +4190,13 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)
 	for (i = 0, j = 0; i < bp->tx_nr_rings; i++) {
 		struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
 		struct bnxt_ring_struct *ring;
+		int nid;
 		u8 qidx;
 
 		ring = &txr->tx_ring_struct;
 
-		rc = bnxt_alloc_ring(bp, &ring->ring_mem);
+		nid = bnxt_cp_num_to_node(bp, txr->bnapi->index);
+		rc = bnxt_alloc_ring(bp, &ring->ring_mem, nid);
 		if (rc)
 			return rc;
 
@@ -4213,7 +4222,7 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)
 		if (!(bp->flags & BNXT_FLAG_UDP_GSO_CAP)) {
 			rc = bnxt_alloc_tx_inline_buf(txr, pdev,
 						      BNXT_SW_USO_MAX_SEGS *
-						      TSO_HEADER_SIZE);
+						      TSO_HEADER_SIZE, nid);
 			if (rc)
 				return rc;
 		}
@@ -4240,12 +4249,15 @@ static void bnxt_free_cp_arrays(struct bnxt_cp_ring_info *cpr)
 	ring->ring_mem.dma_arr = NULL;
 }
 
-static int bnxt_alloc_cp_arrays(struct bnxt_cp_ring_info *cpr, int n)
+static int bnxt_alloc_cp_arrays(struct bnxt_cp_ring_info *cpr, int n,
+				int nid)
 {
-	cpr->cp_desc_ring = kzalloc_objs(*cpr->cp_desc_ring, n);
+	cpr->cp_desc_ring = kcalloc_node(n, sizeof(*cpr->cp_desc_ring),
+					 GFP_KERNEL, nid);
 	if (!cpr->cp_desc_ring)
 		return -ENOMEM;
-	cpr->cp_desc_mapping = kzalloc_objs(*cpr->cp_desc_mapping, n);
+	cpr->cp_desc_mapping = kcalloc_node(n, sizeof(*cpr->cp_desc_mapping),
+					    GFP_KERNEL, nid);
 	if (!cpr->cp_desc_mapping)
 		return -ENOMEM;
 	return 0;
@@ -4272,11 +4284,12 @@ static int bnxt_alloc_all_cp_arrays(struct bnxt *bp)
 
 	for (i = 0; i < bp->cp_nr_rings; i++) {
 		struct bnxt_napi *bnapi = bp->bnapi[i];
-		int rc;
+		int nid, rc;
 
 		if (!bnapi)
 			continue;
-		rc = bnxt_alloc_cp_arrays(&bnapi->cp_ring, n);
+		nid = bnxt_cp_num_to_node(bp, i);
+		rc = bnxt_alloc_cp_arrays(&bnapi->cp_ring, n, nid);
 		if (rc)
 			return rc;
 	}
@@ -4321,13 +4334,13 @@ static void bnxt_free_cp_rings(struct bnxt *bp)
 }
 
 static int bnxt_alloc_cp_sub_ring(struct bnxt *bp,
-				  struct bnxt_cp_ring_info *cpr)
+				  struct bnxt_cp_ring_info *cpr, int nid)
 {
 	struct bnxt_ring_mem_info *rmem;
 	struct bnxt_ring_struct *ring;
 	int rc;
 
-	rc = bnxt_alloc_cp_arrays(cpr, bp->cp_nr_pages);
+	rc = bnxt_alloc_cp_arrays(cpr, bp->cp_nr_pages, nid);
 	if (rc) {
 		bnxt_free_cp_arrays(cpr);
 		return -ENOMEM;
@@ -4339,7 +4352,7 @@ static int bnxt_alloc_cp_sub_ring(struct bnxt *bp,
 	rmem->pg_arr = (void **)cpr->cp_desc_ring;
 	rmem->dma_arr = cpr->cp_desc_mapping;
 	rmem->flags = BNXT_RMEM_RING_PTE_FLAG;
-	rc = bnxt_alloc_ring(bp, rmem);
+	rc = bnxt_alloc_ring(bp, rmem, NUMA_NO_NODE);
 	if (rc) {
 		bnxt_free_ring(bp, rmem);
 		bnxt_free_cp_arrays(cpr);
@@ -4360,7 +4373,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
 		struct bnxt_napi *bnapi = bp->bnapi[i];
 		struct bnxt_cp_ring_info *cpr, *cpr2;
 		struct bnxt_ring_struct *ring;
-		int cp_count = 0, k;
+		int cp_count = 0, k, nid;
 		int rx = 0, tx = 0;
 
 		if (!bnapi)
@@ -4370,7 +4383,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
 		cpr->bnapi = bnapi;
 		ring = &cpr->cp_ring_struct;
 
-		rc = bnxt_alloc_ring(bp, &ring->ring_mem);
+		rc = bnxt_alloc_ring(bp, &ring->ring_mem, NUMA_NO_NODE);
 		if (rc)
 			return rc;
 
@@ -4392,14 +4405,16 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
 			tx = 1;
 		}
 
-		cpr->cp_ring_arr = kzalloc_objs(*cpr, cp_count);
+		nid = bnxt_cp_num_to_node(bp, i);
+		cpr->cp_ring_arr = kcalloc_node(cp_count, sizeof(*cpr),
+						GFP_KERNEL, nid);
 		if (!cpr->cp_ring_arr)
 			return -ENOMEM;
 		cpr->cp_ring_count = cp_count;
 
 		for (k = 0; k < cp_count; k++) {
 			cpr2 = &cpr->cp_ring_arr[k];
-			rc = bnxt_alloc_cp_sub_ring(bp, cpr2);
+			rc = bnxt_alloc_cp_sub_ring(bp, cpr2, nid);
 			if (rc)
 				return rc;
 			cpr2->bnapi = bnapi;
@@ -5411,8 +5426,10 @@ static int bnxt_alloc_stats(struct bnxt *bp)
 	for (i = 0; i < bp->cp_nr_rings; i++) {
 		struct bnxt_napi *bnapi = bp->bnapi[i];
 		struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
+		int nid = bnxt_cp_num_to_node(bp, i);
 
-		cpr->sw_stats = kzalloc_obj(*cpr->sw_stats);
+		cpr->sw_stats = kzalloc_node(sizeof(*cpr->sw_stats), GFP_KERNEL,
+					     nid);
 		if (!cpr->sw_stats)
 			return -ENOMEM;
 
@@ -9201,7 +9218,7 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
 	rmem->flags = BNXT_RMEM_VALID_PTE_FLAG;
 	if (rmem->depth >= 1)
 		rmem->flags |= BNXT_RMEM_USE_FULL_PAGE_FLAG;
-	return bnxt_alloc_ring(bp, rmem);
+	return bnxt_alloc_ring(bp, rmem, NUMA_NO_NODE);
 }
 
 static int bnxt_alloc_ctx_pg_tbls(struct bnxt *bp,
@@ -16501,23 +16518,23 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
 		goto err_rxq_info_unreg;
 
 	ring = &clone->rx_ring_struct;
-	rc = bnxt_alloc_ring(bp, &ring->ring_mem);
+	rc = bnxt_alloc_ring(bp, &ring->ring_mem, nid);
 	if (rc)
 		goto err_free_rx_ring;
 
 	if (bp->flags & BNXT_FLAG_AGG_RINGS) {
 		ring = &clone->rx_agg_ring_struct;
-		rc = bnxt_alloc_ring(bp, &ring->ring_mem);
+		rc = bnxt_alloc_ring(bp, &ring->ring_mem, nid);
 		if (rc)
 			goto err_free_rx_agg_ring;
 
-		rc = bnxt_alloc_rx_agg_bmap(bp, clone);
+		rc = bnxt_alloc_rx_agg_bmap(bp, clone, nid);
 		if (rc)
 			goto err_free_rx_agg_ring;
 	}
 
 	if (bp->flags & BNXT_FLAG_TPA) {
-		rc = bnxt_alloc_one_tpa_info(bp, clone);
+		rc = bnxt_alloc_one_tpa_info(bp, clone, nid);
 		if (rc)
 			goto err_free_tpa_info;
 	}
-- 
2.56.1
Re: [PATCH net-next 3/6] eth: bnxt_en: allocate per-queue SW state on the queue's NUMA node
#18506
Author: Björn Töpel
Date: Wed, 18 Nov 2026 12:37
14 lines
8215 bytes
Jakub Kicinski <kuba@kernel.org> writes:

> Allocate the SW rings, agg bitmap, TPA state, completion ring
> page arrays, completion sub-ring structs, SW stats and the SW USO
> header buffer on the NUMA node of the CPU which will service the queue.
> This lowers the cost of cache misses for NAPI fast path (and xmit, for Tx).
>
> Previous change already allocated the page pools on the right node.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Björn Töpel <bjorn@kernel.org>
Re: [PATCH net-next 3/6] eth: bnxt_en: allocate per-queue SW state on the queue's NUMA node
#18569
Author: Joe Damato
Date: Wed, 18 Nov 2026 14:49
15 lines
11937 bytes
On Tue, Nov 17, 2026 at 06:39:02PM -0800, Jakub Kicinski wrote:
> Allocate the SW rings, agg bitmap, TPA state, completion ring
> page arrays, completion sub-ring structs, SW stats and the SW USO
> header buffer on the NUMA node of the CPU which will service the queue.
> This lowers the cost of cache misses for NAPI fast path (and xmit, for Tx).
> 
> Previous change already allocated the page pools on the right node.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 87 ++++++++++++++---------
>  1 file changed, 52 insertions(+), 35 deletions(-)

Reviewed-by: Joe Damato <joe@dama.to>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads