From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net, michael.chan@broadcom.com
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org,
pavan.chebbi@broadcom.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 2/6] eth: bnxt_en: follow explicitly set IRQ affinity when placing page pool
Date: Tue, 17 Nov 2026 18:39:01 -0800 [thread overview]
Message-ID: <20261118023905.3050661-3-kuba@kernel.org> (raw)
In-Reply-To: <20261118023905.3050661-1-kuba@kernel.org>
The driver picks the NUMA node for each Rx ring's page pool with
cpumask_local_spread() at open. IRQ affinity configured by the user
is already recorded by the driver and persists across close/open
cycles. Use it instead of cpumask_local_spread().
The affinity notifier runs without any of the locks held by
the allocation paths, and copying a multi-word cpumask is not atomic.
Like for the TPH Steering Tag, have the notifier compute the node
(of the first online CPU in the mask) and publish it with WRITE_ONCE().
Queue restart (bnxt_queue_mem_alloc()) needs to resolve the NUMA
node instead of copying the nid of the old page pool.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 5 +++
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 48 +++++++++++++++++++----
2 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 41d05efd6307..86fc2e8a5816 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -2488,6 +2488,11 @@ struct bnxt {
* rather than being our own default placement.
*/
unsigned long *ring_affinity_set;
+ /* Node of the first online CPU in the mask configured from
+ * the outside, NUMA_NO_NODE if none. Written by the affinity
+ * notifier, read locklessly by the allocation paths.
+ */
+ int *ring_nid;
int max_irqs;
int total_irqs;
int ulp_num_msix_want;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 5ad2a3033505..8e8ee02ca8d9 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3818,6 +3818,21 @@ static int bnxt_alloc_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem)
return 0;
}
+/* Node of the CPU expected to service cp ring @n. If the IRQ affinity was
+ * configured from the outside (by the user or irqbalance) the affinity
+ * notifier recorded the node to use, otherwise follow our default spread.
+ */
+static int bnxt_cp_num_to_node(struct bnxt *bp, int n)
+{
+ int nid = READ_ONCE(bp->ring_nid[n]);
+ unsigned int cpu;
+
+ if (nid != NUMA_NO_NODE)
+ return nid;
+ cpu = cpumask_local_spread(n, dev_to_node(&bp->pdev->dev));
+ return cpu_to_node(cpu);
+}
+
static void bnxt_free_one_tpa_info(struct bnxt *bp,
struct bnxt_rx_ring_info *rxr)
{
@@ -4020,8 +4035,7 @@ static int bnxt_alloc_rx_agg_bmap(struct bnxt *bp, struct bnxt_rx_ring_info *rxr
static int bnxt_alloc_rx_rings(struct bnxt *bp)
{
- int numa_node = dev_to_node(&bp->pdev->dev);
- int i, rc = 0, agg_rings = 0, cpu;
+ int i, rc = 0, agg_rings = 0;
if (!bp->rx_ring)
return -ENOMEM;
@@ -4036,8 +4050,7 @@ static int bnxt_alloc_rx_rings(struct bnxt *bp)
ring = &rxr->rx_ring_struct;
- cpu = cpumask_local_spread(i, numa_node);
- cpu_node = cpu_to_node(cpu);
+ cpu_node = bnxt_cp_num_to_node(bp, i);
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);
@@ -11870,6 +11883,8 @@ static void bnxt_irq_affinity_notify(struct irq_affinity_notify *notify,
const cpumask_t *mask)
{
struct bnxt_irq *irq;
+ unsigned int cpu;
+ int nid;
u16 tag;
irq = container_of(notify, struct bnxt_irq, affinity_notify);
@@ -11877,6 +11892,14 @@ static void bnxt_irq_affinity_notify(struct irq_affinity_notify *notify,
cpumask_copy(irq->bp->ring_cpu_mask[irq->ring_nr], mask);
set_bit(irq->ring_nr, irq->bp->ring_affinity_set);
+ /* Allocation paths don't hold any lock which would exclude us,
+ * publish the node to allocate on instead of making them parse
+ * the mask while it may be getting overwritten.
+ */
+ cpu = cpumask_first_and(mask, cpu_online_mask);
+ nid = cpu < nr_cpu_ids ? cpu_to_node(cpu) : NUMA_NO_NODE;
+ WRITE_ONCE(irq->bp->ring_nid[irq->ring_nr], nid);
+
#ifdef CONFIG_RFS_ACCEL
if (irq->bp->dev->rx_cpu_rmap && irq->ring_nr < irq->bp->rx_nr_rings) {
int err;
@@ -11954,9 +11977,16 @@ static int bnxt_alloc_ring_cpu_masks(struct bnxt *bp)
if (!bp->ring_affinity_set)
return -ENOMEM;
- for (i = 0; i < bp->max_irqs; i++)
+ bp->ring_nid = kmalloc_array(bp->max_irqs, sizeof(*bp->ring_nid),
+ GFP_KERNEL);
+ if (!bp->ring_nid)
+ return -ENOMEM;
+
+ for (i = 0; i < bp->max_irqs; i++) {
if (!zalloc_cpumask_var(&bp->ring_cpu_mask[i], GFP_KERNEL))
return -ENOMEM;
+ bp->ring_nid[i] = NUMA_NO_NODE;
+ }
return 0;
}
@@ -11971,6 +12001,8 @@ static void bnxt_free_ring_cpu_masks(struct bnxt *bp)
for (i = 0; i < bp->max_irqs; i++)
free_cpumask_var(bp->ring_cpu_mask[i]);
+ kfree(bp->ring_nid);
+ bp->ring_nid = NULL;
bitmap_free(bp->ring_affinity_set);
bp->ring_affinity_set = NULL;
kfree(bp->ring_cpu_mask);
@@ -12066,6 +12098,7 @@ static int bnxt_request_irq(struct bnxt *bp)
if (!test_bit(i, bp->ring_affinity_set) ||
!cpumask_intersects(cpu_mask, cpu_online_mask)) {
clear_bit(i, bp->ring_affinity_set);
+ WRITE_ONCE(bp->ring_nid[i], NUMA_NO_NODE);
cpumask_clear(cpu_mask);
cpumask_set_cpu(cpumask_local_spread(i, numa_node),
cpu_mask);
@@ -16431,7 +16464,7 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
struct bnxt_rx_ring_info *rxr, *clone;
struct bnxt *bp = netdev_priv(dev);
struct bnxt_ring_struct *ring;
- int rc;
+ int nid, rc;
if (!bp->rx_ring)
return -ENETDOWN;
@@ -16452,7 +16485,8 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
clone->rx_tpa = NULL;
clone->rx_tpa_idx_map = NULL;
- rc = bnxt_alloc_rx_page_pool(bp, clone, rxr->page_pool->p.nid);
+ nid = bnxt_cp_num_to_node(bp, idx);
+ rc = bnxt_alloc_rx_page_pool(bp, clone, nid);
if (rc)
return rc;
--
2.56.1
next prev parent reply other threads:[~2026-11-18 2:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 2:38 [PATCH net-next 0/6] eth: bnxt_en: allocate memory on the right NUMA node Jakub Kicinski
2026-11-18 2:39 ` [PATCH net-next 1/6] eth: bnxt_en: order event data before setting the sp_event bit Jakub Kicinski
2026-11-18 2:39 ` Jakub Kicinski [this message]
2026-11-18 2:39 ` [PATCH net-next 3/6] eth: bnxt_en: allocate per-queue SW state on the queue's NUMA node Jakub Kicinski
2026-11-18 2:39 ` [PATCH net-next 4/6] eth: bnxt_en: explicitly keep device-only memory on the device's node Jakub Kicinski
2026-11-18 2:39 ` [PATCH net-next 5/6] eth: bnxt_en: allocate fast path DMA rings on the queue's NUMA node Jakub Kicinski
2026-11-18 2:39 ` [PATCH net-next 6/6] eth: bnxt_en: restart Rx queues when their IRQ moves to another " Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118023905.3050661-3-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.