Netdev List
 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 v12 10/10] bnge: add cpu_rmap support for IRQ affinity
Date: Sat, 05 Dec 2026 14:46:23 +0000	[thread overview]
Message-ID: <179648198330.3146.10471721168563018721@kernel.org> (raw)
In-Reply-To: <20261201132011.2705569-11-vikas.gupta@broadcom.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The patch builds its own aRFS cpu_rmap handling in
  drivers/net/ethernet/broadcom/bnge/bnge_netdev.c, although the…
- [Low] The new comment on struct bnge_irq
  (drivers/net/ethernet/broadcom/bnge/bnge_resc.h:67) says that @ring_nr…

--

bnge: add cpu_rmap support for IRQ affinity

This patch turns on aRFS for bnge. When NTUPLE is enabled, it allocates
dev->rx_cpu_rmap at open and frees it at close. A driver-installed IRQ
affinity notifier on every RX NQ and on NQ0 keeps the rmap entries up to
date. A new bn->rmap_lock and a saved NQ0 affinity are used to seed entry
0 at open.

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> index de7320521a3e0..54ea9aa5b0d32 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c

[ ... ]

> @@ -2552,14 +2572,155 @@ static void bnge_hwrm_resource_free(struct bnge_net *bn, bool close_path)

[ ... ]

> +static void bnge_register_irq_notifier(struct bnge_net *bn,
> +				       struct bnge_irq *irq)
> +{
> +	struct irq_affinity_notify *notify = &irq->affinity_notify;
> +	int rc;
> +
> +	irq->bn = bn;
> +	notify->irq = irq->vector;
> +	notify->notify = bnge_irq_affinity_notify;
> +	notify->release = bnge_irq_affinity_release;
> +	rc = irq_set_affinity_notifier(irq->vector, notify);

[Severity: Low]
Was the core-managed cpu_rmap path considered here?

The networking core already provides netif_enable_cpu_rmap(), the
rx_cpu_rmap_auto handling in netif_napi_set_irq_locked(),
netif_set_affinity_auto(), and netif_del_cpu_rmap() called from
free_netdev(). ena, ice, iavf and idpf already use it.

bnge already gives the core the IRQ of every NAPI, NQ0 included, in
bnge_init_napi():

	netif_napi_set_irq_locked(&bnapi->napi,
				  bd->irq_tbl[map_idx].vector);

However, it never sets rx_cpu_rmap_auto or irq_affinity_auto. As a
result, netif_napi_set_irq_locked() returns early and the core never
uses that mapping.

An IRQ can only have one irq_affinity_notify attached. This driver
notifier therefore rules out the core notifier on the same vectors. The
commit message explains why irq_cpu_rmap_add() is unsuitable, but it
doesn't mention the core path.

The driver-built approach also adds bn->rmap_lock, the embedded
bn->nq0_aff cpumask and bnge_nq0_seed_cpu_rmap(). It also allocates and
frees dev->rx_cpu_rmap on every open and close, in
bnge_setup_interrupts() and bnge_free_cpu_rmap(). Freeing the rmap at
close opens the window that the comment above bnge_free_cpu_rmap()
describes:

    set_rps_cpu() loads the pointer twice with plain loads, so a reader
    that is between the two loads is not covered; that has to be fixed
    in the core.

A core-managed rmap lives until free_netdev(), so it doesn't have that
window.

The core path looks usable for bnge. When the rmap is full, cpu_rmap_add()
returns -ENOSPC, so TX-only NAPIs past rx_nr_rings would be skipped. With
irq_affinity_auto set, napi_restore_config() calls irq_set_affinity()
when the NAPI is enabled. That might also fix the NQ0 seeding problem
described in the commit message, though this hasn't been confirmed.

Could the core path be used here instead? If not, could the commit
message explain why it doesn't fit bnge?

> +	if (rc)
> +		netdev_warn(bn->netdev,
> +			    "Set affinity notifier failed, IRQ = %d: %d\n",
> +			    irq->vector, rc);
> +}

[ ... ]

> @@ -2583,6 +2744,16 @@ static int bnge_nq_request_irq(struct bnge_net *bn, struct bnge_napi *bnapi)
>  		return rc;
>  
>  	irq->requested = 1;
> +	irq->ring_nr = bnapi->index;
> +
> +	/* The affinity notifier keeps the aRFS rmap entry of this ring
> +	 * current. It does not use cpu_mask, so install it independent of
> +	 * the allocation of the hint mask below. NQ0 is requested at probe,
> +	 * when it has no rx_ring yet, and its notifier must exist from then
> +	 * on.
> +	 */
> +	if (bnapi->rx_ring || bnapi == bn->nq0)
> +		bnge_register_irq_notifier(bn, irq);

[Severity: Low]
This isn't a bug today, but the new comment on struct bnge_irq in
bnge_resc.h says:

	 * @ring_nr is the RX ring (and rmap) index this vector serves.

bnge_nq_request_irq() sets ring_nr = bnapi->index for every open NQ,
before and regardless of the rx_ring check. When BNGE_EN_SHARED_CHNL is
clear, bnge_alloc_core() places the TX rings after the RX rings:

	if (bd->flags & BNGE_EN_SHARED_CHNL)
		j = 0;
	else
		j = bd->rx_nr_rings;

The TX-only NQs then have no rx_ring and get ring_nr >= rx_nr_rings.
That is neither an RX ring index nor a valid rmap index.

Nothing goes out of range today. Those NQs get no notifier, and
bnge_irq_affinity_notify() checks irq->ring_nr < bn->bd->rx_nr_rings.

Could the comment be adjusted, or ring_nr be set only for NQs that serve
an RX ring? Otherwise a later user that trusts the comment could index
bn->rx_ring[] or the rmap past rx_nr_rings.

>  
>  	if (zalloc_cpumask_var(&irq->cpu_mask, GFP_KERNEL)) {
>  		int numa_node = dev_to_node(&bd->pdev->dev);

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201132011.2705569-1-vikas.gupta%40broadcom.com

      reply	other threads:[~2026-12-05 14:46 UTC|newest]

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

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=179648198330.3146.10471721168563018721@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