Re: [PATCH net-next v11 10/10] bnge: add cpu_rmap support for IRQ affinity

From: Vikas Gupta

Date: Tue Dec 01 2026 - 05:12:26 EST


Hi,
I see a valid comment in patch-10 and will send out v12.

Thanks,
Vikas

On Tue, Dec 1, 2026 at 12:09 PM <netdev-bot+sashiko@xxxxxxxxxx> wrote:
>
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 2
>
> 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).
>
> - [Medium] The commit message describes an irq_cpu_rmap_add() design that
> the patch does not implement.
> - [Low] If one ring's rmap entry cannot be filled in, the driver only
> warns and keeps aRFS on with that entry left at its default.
> - [Low] bnge_nq0_seed_cpu_rmap() (bnge_netdev.c:2658-2677) takes NQ0's
> mask from irq_get_affinity_mask(vector), which is…
>
> --
>
> bnge: add cpu_rmap support for IRQ affinity
>
> When CONFIG_RFS_ACCEL is enabled and ntuple is on, this patch allocates
> a cpu_rmap sized to the RX rings and publishes it in dev->rx_cpu_rmap,
> which turns aRFS on. Per-ring IRQ affinity notifiers update the rmap
> entries, and entry 0 is seeded from the affinity of the persistent NQ0
> vector at open.
>
> > If adding an IRQ to the rmap fails for one ring, aRFS is turned off
> > for all rings, because a later ring would otherwise take the free slot
> > and map to the wrong RX queue.
> >
> > NQ0 is requested at probe, before the rmap exists, and is not one of
> > the open NQs that bnge_request_irq() loops over. Add its vector to the
> > rmap first, so that the index of every vector in the rmap is its RX
> > ring index. Otherwise each vector lands one slot too low, and aRFS
> > steers a flow to the wrong RX queue.
>
> [Severity: Medium]
>
> Do these two paragraphs describe what the patch does?
>
> The driver never calls irq_cpu_rmap_add() or cpu_rmap_add(), so no code
> hands out rmap slots in sequence. Every update passes an explicit index:
>
> bnge_irq_affinity_notify():
> rc = cpu_rmap_update(rmap, irq->ring_nr, mask);
>
> bnge_nq0_seed_cpu_rmap():
> rc = cpu_rmap_update(bn->netdev->rx_cpu_rmap, 0, mask);
>
> With explicit indices, a later ring cannot take a free slot, and no vector
> can land one slot too low. The NQ0 step only copies NQ0's current affinity
> into entry 0.
>
> The failure behaviour also differs from the description. On failure,
> bnge_register_irq_notifier(), bnge_irq_affinity_notify() and
> bnge_nq0_seed_cpu_rmap() only call netdev_warn(). dev->rx_cpu_rmap stays
> published and BNGE_NET_EN_NTUPLE is not cleared, so aRFS stays on rather
> than being turned off for all rings.
>
> Is this text left over from an earlier version based on irq_cpu_rmap_add()?
> Could the commit message be updated to describe the explicit-index scheme
> and the warn-only failure handling?
>
> > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> > index de7320521a3e0..d336c0f580b6a 100644
> > --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
>
> [ ... ]
>
> > +static void bnge_nq0_seed_cpu_rmap(struct bnge_net *bn)
> > +{
> > + const struct cpumask *mask;
> > + unsigned int vector;
> > + u16 map_idx;
> > + int rc;
> > +
> > + map_idx = bn->nq0->nq_ring.ring_struct.map_idx;
> > + vector = bn->bd->irq_tbl[map_idx].vector;
> > + mask = irq_get_affinity_mask(vector);
> > +
> > + mutex_lock(&bn->rmap_lock);
> > + if (bn->netdev->rx_cpu_rmap && mask) {
> > + rc = cpu_rmap_update(bn->netdev->rx_cpu_rmap, 0, mask);
>
> [Severity: Low]
>
> Can this seed write a stale mask into entry 0?
>
> irq_get_affinity_mask() returns desc->irq_common_data.affinity. It is read
> here without desc->lock, and any pending affinity move is ignored. The core
> notifier that drives bnge_irq_affinity_notify() for NQ0 uses the pending
> mask instead:
>
> kernel/irq/manage.c:irq_affinity_notify() {
> ...
> if (irq_move_pending(&desc->irq_data))
> irq_get_pending(cpumask, desc);
> else
> cpumask_copy(cpumask, desc->irq_common_data.affinity);
> ...
> }
>
> On a chip with IRQCHIP_MOVE_DEFERRED, such as x86 PCI MSI without
> interrupt remapping, the following sequence looks possible:
>
> - NQ0's smp_affinity is changed. irq_set_affinity_locked() only records
> the new mask as pending and schedules the notify work.
>
> - bnge_open_core() calls disable_irq(vector0) before bnge_request_irq(),
> so the pending move cannot complete in this window.
>
> - The NQ0 notify work runs after bnge_setup_interrupts() has published
> the rmap and writes the new mask into entry 0. Alternatively it ran
> while the interface was down, when the rmap was NULL, and did nothing.
>
> - bnge_nq0_seed_cpu_rmap() then reads the old live mask and writes it
> into entry 0.
>
> - When the move later completes, irq_move_masked_irq() does not
> schedule the notifier again.
>
> Entry 0 would then stay stale until the next NQ0 affinity change. aRFS
> would steer flows from the old CPUs to RX ring 0 while NQ0 runs on the new
> CPUs.
>
> > + if (rc)
> > + netdev_warn(bn->netdev,
> > + "aRFS rmap seed failed: %d\n", rc);
> > + }
> > + mutex_unlock(&bn->rmap_lock);
> > +}
>
> [ ... ]
>
> > @@ -2590,9 +2746,12 @@ static int bnge_nq_request_irq(struct bnge_net *bn, struct bnge_napi *bnapi)
> > irq->have_cpumask = 1;
> > cpumask_set_cpu(cpumask_local_spread(bnapi->index, numa_node),
> > irq->cpu_mask);
> > - if (irq_set_affinity_hint(irq->vector, irq->cpu_mask))
> > + if (irq_set_affinity_and_hint(irq->vector, irq->cpu_mask))
> > bnge_warn(bd, "Set affinity failed, IRQ = %d\n",
> > irq->vector);
> > + } else {
> > + bnge_warn(bd, "No affinity hint mask, IRQ = %d\n",
> > + irq->vector);
> > }
>
> [Severity: Low]
>
> What happens to this ring's rmap entry when zalloc_cpumask_var() fails?
>
> In that case irq_set_affinity_and_hint() is never called and the notify
> work never runs for this ring, so its rmap entry is never written. But
> bnge_setup_interrupts() has already published dev->rx_cpu_rmap, and
> alloc_cpu_rmap() only sets placeholder values:
>
> lib/cpu_rmap.c:alloc_cpu_rmap() {
> ...
> for_each_possible_cpu(cpu) {
> rmap->near[cpu].index = cpu % size;
> rmap->near[cpu].dist = CPU_RMAP_DIST_INF;
> }
> ...
> }
>
> The same applies when cpu_rmap_update() returns -ENOMEM in
> bnge_irq_affinity_notify() or bnge_nq0_seed_cpu_rmap(), since both only
> warn. A failed irq_set_affinity_notifier() in bnge_register_irq_notifier()
> is handled the same way, although it can only fail for a missing desc or
> an NMI.
>
> Would set_rps_cpu() then keep steering flows by the cpu % size placeholder
> while aRFS stays on? Those RX queues' IRQs may not be near the consuming
> CPU.
>
> This needs CONFIG_CPUMASK_OFFSTACK=y and an allocation failure, and it only
> affects steering quality. It does differ from the commit message's
> description that a per-ring failure turns aRFS off.
>
> > return 0;
> > }
>
> [ ... ]
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130055736.2306367-1-vikas.gupta%40broadcom.com

pw-bot: cr

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature