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 v10 10/10] bnge: add cpu_rmap support for IRQ affinity
Date: Sun, 29 Nov 2026 12:46:49 +0000 [thread overview]
Message-ID: <179595640978.3146.2248814989251776899@kernel.org> (raw)
In-Reply-To: <20261125115434.2080590-11-vikas.gupta@broadcom.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · 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] RX ring 0's slot in the aRFS cpu_rmap is never filled, so aRFS
still steers flows on ring 0's CPU to the wrong RX queue.
- [Medium] The teardown in bnge_free_cpu_rmap() assumes each reader loads
rx_cpu_rmap once, but set_rps_cpu() loads it twice.
--
bnge: add cpu_rmap support for IRQ affinity
When CONFIG_RFS_ACCEL and NTUPLE are enabled, this patch allocates a
cpu_rmap for the RX IRQ vectors, which turns aRFS on for bnge. At open,
NQ0 (requested at probe) is added to the rmap first, so each vector's
rmap index matches its RX ring index. If adding an IRQ to the rmap fails,
aRFS is turned off for all rings.
> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> index de7320521a3e0..b031b3c0af0b4 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
[ ... ]
> @@ -2569,6 +2583,50 @@ static void bnge_nq_free_irq(struct bnge_net *bn, struct bnge_napi *bnapi)
> irq->requested = 0;
> }
>
> +#ifdef CONFIG_RFS_ACCEL
> +/* set_rps_cpu() reads rx_cpu_rmap under rcu_read_lock(). Hide the pointer and
> + * wait for readers that already loaded it before the rmap is freed.
> + */
> +static void bnge_free_cpu_rmap(struct bnge_net *bn)
> +{
> + struct cpu_rmap *rmap = bn->netdev->rx_cpu_rmap;
> +
> + if (!rmap)
> + return;
> +
> + WRITE_ONCE(bn->netdev->rx_cpu_rmap, NULL);
> + synchronize_net();
> + free_irq_cpu_rmap(rmap);
> +}
[Severity: Medium]
Does this sequence give the protection the comment describes?
set_rps_cpu() in net/core/dev.c loads dev->rx_cpu_rmap twice, with two
separate plain loads:
net/core/dev.c:set_rps_cpu() {
...
if (!skb_rx_queue_recorded(skb) || !dev->rx_cpu_rmap ||
...
rxq_index = cpu_rmap_lookup_index(dev->rx_cpu_rmap, next_cpu);
...
}
Suppose the WRITE_ONCE(..., NULL) above lands on another CPU between
those two loads. The reader passes the NULL check, then reloads NULL, and
cpu_rmap_lookup_index() dereferences a NULL rmap. Because
synchronize_net() runs after the store, it can't prevent this.
To hit this, a reader has to be in set_rps_cpu() for this netdev while
bnge_free_cpu_rmap() runs. That can happen from
bnge_close_core()->bnge_free_irq(), or from the irq_cpu_rmap_add()
failure path in bnge_nq_add_cpu_rmap().
bnge's own NAPI is already disabled by then. Skbs injected into the
device with a recorded rx queue can still reach get_rps_cpu(), though.
One example is a TC bpf_redirect() with BPF_F_INGRESS into bnge, which
goes through __dev_forward_skb()->netif_rx(). is_skb_forwardable() only
checks IFF_UP, and __dev_close_many() clears that flag only after
ndo_stop returns. This also needs RPS/RFS and NTUPLE to be configured,
and the window is narrow.
The double load is in core code. Would set_rps_cpu() need to read
rx_cpu_rmap once with READ_ONCE() for this teardown to be safe? If not,
should the comment here be changed so it doesn't overstate what the
sequence guarantees?
[ ... ]
> @@ -2616,6 +2678,13 @@ static int bnge_request_irq(struct bnge_net *bn)
> netdev_err(bn->netdev, "bnge_setup_interrupts err: %d\n", rc);
> return rc;
> }
> +
> + /* NQ0 is requested at probe, before the rmap exists, and is not one
> + * of the open NQs below. Add it first, so that the rmap index of
> + * every vector is its RX ring index.
> + */
> + bnge_nq_add_cpu_rmap(bn, bn->bnapi[0]);
[Severity: High]
Does RX ring 0's slot in the rmap ever get filled in?
NQ0's vector was bound and given its affinity hint at probe, while
dev->rx_cpu_rmap was still NULL:
bnge_nq0_init()
bnge_nq_request_irq()
bnge_nq_add_cpu_rmap() <- returns early, rmap is NULL
request_irq()
irq_set_affinity_hint(irq->vector, irq->cpu_mask)
At open, irq_cpu_rmap_add() only calls cpu_rmap_add() and
irq_set_affinity_notifier(). irq_set_affinity_notifier() installs
desc->affinity_notify but does not schedule an initial notification.
irq_set_affinity_locked() schedules one only when the affinity changes.
So it looks like cpu_rmap_update(rmap, 0, ...) never runs for NQ0.
This also goes against the kernel-doc for irq_cpu_rmap_add():
Must be called in process context, after the IRQ is allocated but
before it is bound with request_irq().
The open NQs avoid this, because bnge_nq_request_irq() adds the notifier
before it calls irq_set_affinity_hint().
alloc_irq_cpu_rmap() starts every CPU at CPU_RMAP_DIST_INF. When rings
1..N-1 get their notifications, NQ0's CPU would therefore be assigned to
the nearest other ring.
For flows consumed on ring 0's CPU, wouldn't
set_rps_cpu()->cpu_rmap_lookup_index() then return some ring k != 0?
bnge_rx_flow_steer() would then program the NTUPLE filter for that other
ring.
free_irq_cpu_rmap() removes NQ0's notifier at close. That means this
would happen again on every open, unless something outside the driver
changes NQ0's affinity (irqbalance, or a write to /proc/irq).
The comment above and the commit message say the NQ0 handling stops aRFS
from steering flows to the wrong RX queue. The slot order looks right,
but slot 0 doesn't seem to get populated.
Could NQ0's affinity be applied again after irq_cpu_rmap_add() succeeds?
One option is to call irq_set_affinity_hint() again for NQ0's vector.
Another is to seed slot 0 directly with cpu_rmap_update() from the IRQ's
current affinity.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125115434.2080590-1-vikas.gupta%40broadcom.com
prev parent reply other threads:[~2026-11-29 12:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:54 [PATCH net-next v10 00/10] add features to bnge Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 01/10] bnge: restructure VNIC and filter code Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 02/10] bnge: add NTUPLE/ARFS VNIC Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko
2026-11-25 11:54 ` [PATCH net-next v10 03/10] bnge: add helper functions for multi RSS contexts Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 04/10] bnge: add RXFH ethtool support Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 05/10] bnge: add ethtool support to manage RSS contexts Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko
2026-11-25 11:54 ` [PATCH net-next v10 06/10] bnge: remove refcount from L2 filter Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 07/10] bnge: add NTUPLE filter infrastructure Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko
2026-11-25 11:54 ` [PATCH net-next v10 08/10] bnge: add NTUPLE filter support in ethtool Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko
2026-11-25 11:54 ` [PATCH net-next v10 09/10] bnge: add aRFS flow steering ndo support Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko
2026-11-25 11:54 ` [PATCH net-next v10 10/10] bnge: add cpu_rmap support for IRQ affinity Vikas Gupta
2026-11-29 12: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=179595640978.3146.2248814989251776899@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