bnxt_en: Allocate page pool per numa node
authorSomnath Kotur <somnath.kotur@broadcom.com>
Tue, 2 Apr 2024 09:37:49 +0000 (02:37 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 4 Apr 2024 16:13:19 +0000 (09:13 -0700)
Driver's Page Pool allocation code looks at the node local
to the PCIe device to determine where to allocate memory.
In scenarios where the core count per NUMA node is low (< default rings)
it makes sense to exhaust page pool allocations on
Node 0 first and then moving on to allocating page pools
for the remaining rings from Node 1.

With this patch, and the following configuration on the NIC
$ ethtool -L ens1f0np0 combined 16
(core count/node = 12, first 12 rings on node#0, last 4 rings node#1)
and traffic redirected to a ring on node#1 , we see a performance
improvement of ~20%

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/20240402093753.331120-4-pavan.chebbi@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index 44b9332c147e3df6571e2047697d0acaaa8eccb5..9fca1dee64869c30325209808c1245abe2c5ad94 100644 (file)
@@ -3559,14 +3559,15 @@ static void bnxt_free_rx_rings(struct bnxt *bp)
 }
 
 static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
-                                  struct bnxt_rx_ring_info *rxr)
+                                  struct bnxt_rx_ring_info *rxr,
+                                  int numa_node)
 {
        struct page_pool_params pp = { 0 };
 
        pp.pool_size = bp->rx_agg_ring_size;
        if (BNXT_RX_PAGE_MODE(bp))
                pp.pool_size += bp->rx_ring_size;
-       pp.nid = dev_to_node(&bp->pdev->dev);
+       pp.nid = numa_node;
        pp.napi = &rxr->bnapi->napi;
        pp.netdev = bp->dev;
        pp.dev = &bp->pdev->dev;
@@ -3586,7 +3587,8 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
 
 static int bnxt_alloc_rx_rings(struct bnxt *bp)
 {
-       int i, rc = 0, agg_rings = 0;
+       int numa_node = dev_to_node(&bp->pdev->dev);
+       int i, rc = 0, agg_rings = 0, cpu;
 
        if (!bp->rx_ring)
                return -ENOMEM;
@@ -3597,10 +3599,15 @@ static int bnxt_alloc_rx_rings(struct bnxt *bp)
        for (i = 0; i < bp->rx_nr_rings; i++) {
                struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
                struct bnxt_ring_struct *ring;
+               int cpu_node;
 
                ring = &rxr->rx_ring_struct;
 
-               rc = bnxt_alloc_rx_page_pool(bp, rxr);
+               cpu = cpumask_local_spread(i, numa_node);
+               cpu_node = cpu_to_node(cpu);
+               netdev_dbg(bp->dev, "Allocating page pool for rx_ring[%d] on numa_node: %d\n",
+                          i, cpu_node);
+               rc = bnxt_alloc_rx_page_pool(bp, rxr, cpu_node);
                if (rc)
                        return rc;