Thread View: linux.kernel.netdev
5 messages
5 total messages
Started by Jakub Kicinski
Wed, 18 Nov 2026 02:39
[PATCH net-next 6/6] eth: bnxt_en: restart Rx queues when their IRQ moves to another NUMA node
Author: Jakub Kicinski
Date: Wed, 18 Nov 2026 02:39
Date: Wed, 18 Nov 2026 02:39
132 lines
12235 bytes
12235 bytes
Rx queue memory is allocated on the node of the CPU servicing the queue
when the device is opened. On a running device it only follows IRQ
affinity changes if TPH is enabled, as a side effect of the queue
restart which applies the new TPH Steering Tag.
Schedule the affinity update work whenever the device supports the
queue API, not just when TPH Steering Tag changed. Queue restart places
all the memory it reallocates, other than the ring page tables, on
the page pool's node, so compare the page pool's nid to decide if
the queue has to move.
Since we need queue state of the currently allocated queue to compare
nid - check that the device is still up after errors.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +-
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 46 ++++++++++++++---------
2 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 86fc2e8a5816..4b80b20288ba 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -2656,7 +2656,7 @@ struct bnxt {
#define BNXT_RING_COAL_NOW_SP_EVENT 17
#define BNXT_FW_RESET_NOTIFY_SP_EVENT 18
#define BNXT_FW_EXCEPTION_SP_EVENT 19
-#define BNXT_TPH_UPDATE_SP_EVENT 20
+#define BNXT_IRQ_AFFINITY_SP_EVENT 20
#define BNXT_LINK_CFG_CHANGE_SP_EVENT 21
#define BNXT_THERMAL_THRESHOLD_SP_EVENT 22
#define BNXT_FW_ECHO_REQUEST_SP_EVENT 23
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 134b24842c4f..5f4a8db1f8b5 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -11931,18 +11931,17 @@ static void bnxt_irq_affinity_notify(struct irq_affinity_notify *notify,
}
#endif
- if (!irq->bp->tph_mode)
+ /* Only Rx queues can be restarted to follow the IRQ */
+ if (!BNXT_SUPPORTS_QUEUE_API(irq->bp) ||
+ irq->ring_nr >= irq->bp->rx_nr_rings)
return;
- if (irq->ring_nr >= irq->bp->rx_nr_rings)
- return;
+ if (irq->bp->tph_mode &&
+ !pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM,
+ cpumask_first(mask), &tag))
+ WRITE_ONCE(irq->new_tag, tag);
- if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM,
- cpumask_first(mask), &tag))
- return;
-
- WRITE_ONCE(irq->new_tag, tag);
- bnxt_queue_sp_work(irq->bp, BNXT_TPH_UPDATE_SP_EVENT);
+ bnxt_queue_sp_work(irq->bp, BNXT_IRQ_AFFINITY_SP_EVENT);
}
static void bnxt_irq_affinity_release(struct kref *ref)
@@ -14663,7 +14662,10 @@ static void bnxt_rtnl_unlock_sp(struct bnxt *bp)
rtnl_unlock();
}
-static void bnxt_tph_update(struct bnxt *bp)
+/* Restart the Rx queues whose IRQ moved, if the move changed the TPH
+ * Steering Tag or the node the queue memory should be allocated on.
+ */
+static void bnxt_irq_affinity_update(struct bnxt *bp)
{
struct net_device *dev = bp->dev;
int i;
@@ -14673,6 +14675,8 @@ static void bnxt_tph_update(struct bnxt *bp)
goto unlock;
for (i = 0; i < bp->rx_nr_rings; i++) {
+ struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
+ bool new_tag = false, new_node = false;
struct bnxt_irq *irq;
int map_idx, err;
u16 tag;
@@ -14680,20 +14684,26 @@ static void bnxt_tph_update(struct bnxt *bp)
map_idx = bnxt_cp_num_to_irq_num(bp, i);
irq = &bp->irq_tbl[map_idx];
tag = READ_ONCE(irq->new_tag);
- if (irq->tag == tag)
+ if (irq->tag != tag &&
+ !pcie_tph_set_st_entry(bp->pdev, irq->msix_nr, tag))
+ new_tag = true;
+ if (rxr->page_pool->p.nid != bnxt_cp_num_to_node(bp, i))
+ new_node = true;
+ if (!new_tag && !new_node)
continue;
- if (pcie_tph_set_st_entry(bp->pdev, irq->msix_nr, tag))
- continue;
-
- err = netdev_rx_queue_restart(dev, irq->ring_nr);
+ err = netdev_rx_queue_restart(dev, i);
if (err) {
netdev_err(dev, "RX queue restart failed: err=%d\n",
err);
+ /* Failing to start a new queue may close the device */
+ if (!test_bit(BNXT_STATE_OPEN, &bp->state))
+ break;
continue;
}
- irq->tag = tag;
+ if (new_tag)
+ irq->tag = tag;
}
unlock:
@@ -15137,8 +15147,8 @@ static void bnxt_sp_task(struct work_struct *work)
bnxt_devlink_health_fw_report(bp);
}
- if (test_and_clear_bit(BNXT_TPH_UPDATE_SP_EVENT, &bp->sp_event))
- bnxt_tph_update(bp);
+ if (test_and_clear_bit(BNXT_IRQ_AFFINITY_SP_EVENT, &bp->sp_event))
+ bnxt_irq_affinity_update(bp);
smp_mb__before_atomic();
clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
--
2.56.1
Re: [PATCH net-next 6/6] eth: bnxt_en: restart Rx queues when their IRQ moves to another NUMA node
Author: Björn Töpel
Date: Wed, 18 Nov 2026 12:50
Date: Wed, 18 Nov 2026 12:50
20 lines
8572 bytes
8572 bytes
Jakub Kicinski <kuba@kernel.org> writes: > Rx queue memory is allocated on the node of the CPU servicing the queue > when the device is opened. On a running device it only follows IRQ > affinity changes if TPH is enabled, as a side effect of the queue > restart which applies the new TPH Steering Tag. > > Schedule the affinity update work whenever the device supports the > queue API, not just when TPH Steering Tag changed. Queue restart places > all the memory it reallocates, other than the ring page tables, on > the page pool's node, so compare the page pool's nid to decide if > the queue has to move. > > Since we need queue state of the currently allocated queue to compare > nid - check that the device is still up after errors. > > Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Björn Töpel <bjorn@kernel.org>
Re: [PATCH net-next 6/6] eth: bnxt_en: restart Rx queues when their IRQ moves to another NUMA node
Author: Joe Damato
Date: Wed, 18 Nov 2026 15:01
Date: Wed, 18 Nov 2026 15:01
47 lines
13307 bytes
13307 bytes
On Tue, Nov 17, 2026 at 06:39:05PM -0800, Jakub Kicinski wrote: > Rx queue memory is allocated on the node of the CPU servicing the queue > when the device is opened. On a running device it only follows IRQ > affinity changes if TPH is enabled, as a side effect of the queue > restart which applies the new TPH Steering Tag. > > Schedule the affinity update work whenever the device supports the > queue API, not just when TPH Steering Tag changed. Queue restart places > all the memory it reallocates, other than the ring page tables, on > the page pool's node, so compare the page pool's nid to decide if > the queue has to move. > > Since we need queue state of the currently allocated queue to compare > nid - check that the device is still up after errors. > > Signed-off-by: Jakub Kicinski <kuba@kernel.org> > --- > drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- > drivers/net/ethernet/broadcom/bnxt/bnxt.c | 46 ++++++++++++++--------- > 2 files changed, 29 insertions(+), 19 deletions(-) > > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c > index 134b24842c4f..5f4a8db1f8b5 100644 > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c > @@ -11931,18 +11931,17 @@ static void bnxt_irq_affinity_notify(struct irq_affinity_notify *notify, > } > #endif > > - if (!irq->bp->tph_mode) > + /* Only Rx queues can be restarted to follow the IRQ */ > + if (!BNXT_SUPPORTS_QUEUE_API(irq->bp) || > + irq->ring_nr >= irq->bp->rx_nr_rings) > return; > > - if (irq->ring_nr >= irq->bp->rx_nr_rings) > - return; > + if (irq->bp->tph_mode && > + !pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM, > + cpumask_first(mask), &tag)) nit: this one is tough. i feel like this is super dense when wrapped this way, but i am not sure if there is any way to avoid this without making the code uglier. Reviewed-by: Joe Damato <joe@dama.to>
Re: [PATCH net-next 6/6] eth: bnxt_en: restart Rx queues when their IRQ moves to another NUMA node
Author: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 03:21
Date: Thu, 19 Nov 2026 03:21
177 lines
14432 bytes
14432 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 2 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The new error handling in bnxt_irq_affinity_update() cannot
work, and the path it targets oopses.
- [High] bnxt_irq_affinity_update() takes only the netdev instance lock,
via bnxt_lock_sp() (not bnxt_rtnl_lock_sp()), before calling…
- [Medium] The code restarts more queues than the commit message and the
new function comment describe ('Restart the Rx queues whose IRQ…
--
eth: bnxt_en: restart Rx queues when their IRQ moves to another NUMA node
This patch schedules the IRQ affinity update work on every device that
supports the queue API, instead of only when the TPH Steering Tag changes.
The work restarts an Rx queue when its page pool's nid differs from the
node of the CPU servicing the IRQ. After a failed restart it checks that
the device is still open.
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 134b24842c4f2..5f4a8db1f8b58 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
[ ... ]
> @@ -14663,7 +14662,10 @@ static void bnxt_rtnl_unlock_sp(struct bnxt *bp)
> rtnl_unlock();
> }
>
> -static void bnxt_tph_update(struct bnxt *bp)
> +/* Restart the Rx queues whose IRQ moved, if the move changed the TPH
> + * Steering Tag or the node the queue memory should be allocated on.
> + */
> +static void bnxt_irq_affinity_update(struct bnxt *bp)
> {
> struct net_device *dev = bp->dev;
> int i;
[ ... ]
> @@ -14680,20 +14684,26 @@ static void bnxt_tph_update(struct bnxt *bp)
> map_idx = bnxt_cp_num_to_irq_num(bp, i);
> irq = &bp->irq_tbl[map_idx];
> tag = READ_ONCE(irq->new_tag);
> - if (irq->tag == tag)
> - continue;
> -
> - if (pcie_tph_set_st_entry(bp->pdev, irq->msix_nr, tag))
> + if (irq->tag != tag &&
> + !pcie_tph_set_st_entry(bp->pdev, irq->msix_nr, tag))
> + new_tag = true;
> + if (rxr->page_pool->p.nid != bnxt_cp_num_to_node(bp, i))
> + new_node = true;
[Severity: Medium]
The new function comment says only "Rx queues whose IRQ moved" are
restarted. Is that what this loop does?
An affinity notification for any one Rx IRQ queues
BNXT_IRQ_AFFINITY_SP_EVENT. This loop then compares every ring's
page_pool nid against bnxt_cp_num_to_node(bp, i), whether or not that
ring's IRQ moved.
For rings whose affinity was never set, bnxt_request_irq() leaves
ring_nid[i] as NUMA_NO_NODE. bnxt_cp_num_to_node() then falls back to:
cpu = cpumask_local_spread(n, dev_to_node(&bp->pdev->dev));
return cpu_to_node(cpu);
That result depends on cpu_online_mask at the time of the call.
After CPU hotplug (for example SMT disable or offlining CPUs), can this
fallback pick a different node from the one used at open? If so, moving
one unrelated IRQ would restart these other queues and move their memory
to the new default-spread node.
The comment in bnxt_request_irq() says this placement is "just a hint",
so the new node may not match where the IRQ actually runs.
> + if (!new_tag && !new_node)
> continue;
>
> - err = netdev_rx_queue_restart(dev, irq->ring_nr);
> + err = netdev_rx_queue_restart(dev, i);
> if (err) {
> netdev_err(dev, "RX queue restart failed: err=%d\n",
> err);
> + /* Failing to start a new queue may close the device */
> + if (!test_bit(BNXT_STATE_OPEN, &bp->state))
> + break;
[Severity: High]
If the restart fails because the device was closed, can this check ever
be reached? Here is the sequence I'm looking at:
bnxt_irq_affinity_update()
netdev_rx_queue_restart(dev, i)
netdev_rx_queue_reconfig()
ndo_queue_stop(old_mem) /* succeeds */
bnxt_queue_start(new_mem)
/* clone page_pool, rings and rx_tpa moved into bp->rx_ring[idx] */
bnxt_hwrm_rx_ring_alloc() fails -> err_reset
netif_close(dev)
bnxt_close()->bnxt_close_nic()->__bnxt_close_nic()
bnxt_free_mem(bp, true)
kfree(bp->rx_ring);
bp->rx_ring = NULL;
err_start_queue:
bnxt_queue_start(old_mem)
rxr = &bp->rx_ring[idx];
rxr->rx_prod = clone->rx_prod; /* bp->rx_ring is NULL */
Wouldn't this hit a NULL pointer dereference in the sp workqueue while
netdev_lock is held, before control returns to this check?
If that step were survived, err_free_new_queue_mem would call
ndo_queue_mem_free(dev, new_mem). That runs page_pool_destroy() and
bnxt_free_ring() a second time on resources bnxt_free_mem() already
released.
The commit message says "check that the device is still up after
errors", which relies on this path returning normally.
Before this patch the path ran only on TPH Steering Tag changes.
bnxt_irq_affinity_notify() now queues the work on every queue-API PF,
and any cross-node Rx IRQ move restarts a queue. irqbalance or a write
to /proc/irq/N/smp_affinity is enough to trigger it. An HWRM failure
during queue start is the only other precondition.
[Severity: High]
bnxt_irq_affinity_update() starts with bnxt_lock_sp(bp). That only takes
netdev_lock(bp->dev), not RTNL.
The new comment expects this restart to close the device. The close
happens via bnxt_queue_start() err_reset -> netif_close(dev) ->
netif_close_many() -> __dev_close_many(), which begins with:
ASSERT_RTNL();
might_sleep();
It then calls the NETDEV_GOING_DOWN notifiers, dev_deactivate_many(),
rtmsg_ifinfo() and the NETDEV_DOWN notifiers.
Doesn't all of that run without RTNL here? That would trigger the
assertion and race with other RTNL holders.
Would bnxt_rtnl_lock_sp()/bnxt_rtnl_unlock_sp() be more appropriate,
as bnxt_reset() uses?
The old bnxt_tph_update() used the same helper, but it only ran on TPH
tag changes. With this patch the path runs for any cross-node IRQ move
on a queue-API PF. In the same failure, the core rollback then hits the
NULL bp->rx_ring dereference described above.
> continue;
> }
>
> - irq->tag = tag;
> + if (new_tag)
> + irq->tag = tag;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118023905.3050661-1-kuba%40kernel.org
Re: [PATCH net-next 6/6] eth: bnxt_en: restart Rx queues when their IRQ moves to another NUMA node
Author: Jakub Kicinski
Date: Thu, 19 Nov 2026 22:30
Date: Thu, 19 Nov 2026 22:30
17 lines
8556 bytes
8556 bytes
On Wed, 18 Nov 2026 17:24:12 -0800 Michael Chan wrote: > queue restart already has the code to do HWRM_RING_FREE of the CP ring > to program the new TPH tag. We can add the missing logic to > re-allocate the CP ring pages from the proper NUMA. Since we are > paying the heavy price for a ring restart, should we include the CP > ring to make it more complete? I coded this up. AI review thing popped up the problem that re-allocating CP rings causes loss of IRQ moderation settings. This seems net-worthy to me :S Attaching a memory provider on a machine with TPH will lead to loss of coalescing settings. Quite unpleasant for the -irq settings in particular. Can I send out the coal fixes for net and this series without the CP realloc? I'd follow up with the CP realloc after the net->net-next merge which we just missed :(
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