mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: vikas.gupta@broadcom.com
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	bhargava.marreddy@broadcom.com, rahul-rg.gupta@broadcom.com,
	vsrama-krishna.nemani@broadcom.com,
	rajashekar.hudumula@broadcom.com, dharmender.garg@broadcom.com,
	ajit.khaparde@broadcom.com
Subject: Re: [PATCH net-next v11 10/10] bnge: add cpu_rmap support for IRQ affinity
Date: Tue, 01 Dec 2026 06:39:46 +0000	[thread overview]
Message-ID: <179610718694.3146.14417433453170301894@kernel.org> (raw)
In-Reply-To: <20261130055736.2306367-11-vikas.gupta@broadcom.com>

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

  reply	other threads:[~2026-12-01  6:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  5:57 [PATCH net-next v11 00/10] add features to bnge Vikas Gupta
2026-11-30  5:57 ` [PATCH net-next v11 01/10] bnge: restructure VNIC and filter code Vikas Gupta
2026-11-30  5:57 ` [PATCH net-next v11 02/10] bnge: add NTUPLE/ARFS VNIC Vikas Gupta
2026-12-01  6:39   ` netdev-bot+sashiko
2026-11-30  5:57 ` [PATCH net-next v11 03/10] bnge: add helper functions for multi RSS contexts Vikas Gupta
2026-12-01  6:39   ` netdev-bot+sashiko
2026-11-30  5:57 ` [PATCH net-next v11 04/10] bnge: add RXFH ethtool support Vikas Gupta
2026-12-01  6:39   ` netdev-bot+sashiko
2026-11-30  5:57 ` [PATCH net-next v11 05/10] bnge: add ethtool support to manage RSS contexts Vikas Gupta
2026-12-01  6:39   ` netdev-bot+sashiko
2026-11-30  5:57 ` [PATCH net-next v11 06/10] bnge: remove refcount from L2 filter Vikas Gupta
2026-11-30  5:57 ` [PATCH net-next v11 07/10] bnge: add NTUPLE filter infrastructure Vikas Gupta
2026-12-01  6:39   ` netdev-bot+sashiko
2026-11-30  5:57 ` [PATCH net-next v11 08/10] bnge: add NTUPLE filter support in ethtool Vikas Gupta
2026-12-01  6:39   ` netdev-bot+sashiko
2026-11-30  5:57 ` [PATCH net-next v11 09/10] bnge: add aRFS flow steering ndo support Vikas Gupta
2026-12-01  6:39   ` netdev-bot+sashiko
2026-11-30  5:57 ` [PATCH net-next v11 10/10] bnge: add cpu_rmap support for IRQ affinity Vikas Gupta
2026-12-01  6:39   ` netdev-bot+sashiko [this message]
2026-12-01 10:12     ` Vikas Gupta

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=179610718694.3146.14417433453170301894@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=ajit.khaparde@broadcom.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bhargava.marreddy@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=dharmender.garg@broadcom.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rahul-rg.gupta@broadcom.com \
    --cc=rajashekar.hudumula@broadcom.com \
    --cc=vikas.gupta@broadcom.com \
    --cc=vsrama-krishna.nemani@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®