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 v8 10/10] bnge: add cpu_rmap support for IRQ affinity
Date: Thu, 19 Nov 2026 17:09:12 +0000 [thread overview]
Message-ID: <179510815274.3136.16405156057280346310@kernel.org> (raw)
In-Reply-To: <20261116140653.1685797-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] bnge_free_cpu_rmap()
(drivers/net/ethernet/broadcom/bnge/bnge_netdev.c) tears down…
--
bnge: add cpu_rmap support for IRQ affinity
This patch allocates and fills a cpu_rmap for the bnge RX IRQ vectors
when CONFIG_RFS_ACCEL is set. That sets dev->rx_cpu_rmap and turns aRFS
on for the driver. It also adds bnge_free_cpu_rmap(), which clears and
frees the rmap from bnge_free_irq().
> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> index 0e7c506af402c..507f920ea1d3f 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
[ ... ]
> @@ -2496,12 +2510,35 @@ static void bnge_hwrm_resource_free(struct bnge_net *bn, bool close_path)
> bnge_hwrm_stat_ctx_free(bn);
> }
>
> +#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: Low]
Does the reader in set_rps_cpu() give the guarantee this comment relies
on?
The ordering here does prevent a use-after-free. However, set_rps_cpu()
in net/core/dev.c does not take a single snapshot of the pointer. It
loads dev->rx_cpu_rmap twice with plain loads, with no READ_ONCE() and
no __rcu annotation:
net/core/dev.c:set_rps_cpu() {
...
if (!skb_rx_queue_recorded(skb) || !dev->rx_cpu_rmap ||
!(dev->features & NETIF_F_NTUPLE))
goto out;
rxq_index = cpu_rmap_lookup_index(dev->rx_cpu_rmap, next_cpu);
...
}
Suppose the WRITE_ONCE() above lands between those two loads. The
reader then passes the NULL check and calls cpu_rmap_lookup_index()
with a NULL rmap. synchronize_net() does not help here, because the
reader is already inside its RCU section. The race is between the two
loads, not between the reader and the free.
The teardown runs from ndo_stop:
bnge_close()->bnge_close_core()->bnge_free_irq()->bnge_free_cpu_rmap()
IFF_UP is still set at this point. That means skbs injected into the
bnge ingress path, for example via bpf_redirect() with BPF_F_INGRESS,
dev_forward_skb() or tc mirred ingress, could still reach
netif_rx()->get_rps_cpu()->set_rps_cpu() for this device.
In practice the compiler will most likely merge the two loads into one.
If so, the visible result would be a KCSAN data race report against
this WRITE_ONCE() rather than an oops. Before this patch bnge never set
rx_cpu_rmap, so set_rps_cpu() always took the early exit for this
device.
Would it make sense to have set_rps_cpu() take one READ_ONCE() snapshot
of dev->rx_cpu_rmap? Alternatively, the driver could avoid clearing the
pointer while readers can still run. Either way, the comment above
should probably be adjusted to match.
> +#else
> +static void bnge_free_cpu_rmap(struct bnge_net *bn)
> +{
> +}
> +#endif
> +
> static void bnge_free_irq(struct bnge_net *bn)
> {
> struct bnge_dev *bd = bn->bd;
> struct bnge_irq *irq;
> int i;
>
> + bnge_free_cpu_rmap(bn);
> +
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116140653.1685797-1-vikas.gupta%40broadcom.com
prev parent reply other threads:[~2026-11-19 17:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 14:06 [PATCH net-next v8 00/10] add features to bnge Vikas Gupta
2026-11-16 14:06 ` [PATCH net-next v8 01/10] bnge: restructure VNIC and filter code Vikas Gupta
2026-11-16 14:06 ` [PATCH net-next v8 02/10] bnge: add NTUPLE/ARFS VNIC Vikas Gupta
2026-11-19 17:09 ` netdev-bot+sashiko
2026-11-16 14:06 ` [PATCH net-next v8 03/10] bnge: add helper functions for multi RSS contexts Vikas Gupta
2026-11-16 14:06 ` [PATCH net-next v8 04/10] bnge: add RXFH ethtool support Vikas Gupta
2026-11-19 17:09 ` netdev-bot+sashiko
2026-11-16 14:06 ` [PATCH net-next v8 05/10] bnge: add ethtool support to manage RSS contexts Vikas Gupta
2026-11-19 17:09 ` netdev-bot+sashiko
2026-11-16 14:06 ` [PATCH net-next v8 06/10] bnge: remove refcount from L2 filter Vikas Gupta
2026-11-16 14:06 ` [PATCH net-next v8 07/10] bnge: add NTUPLE filter infrastructure Vikas Gupta
2026-11-19 17:09 ` netdev-bot+sashiko
2026-11-16 14:06 ` [PATCH net-next v8 08/10] bnge: add NTUPLE filter support in ethtool Vikas Gupta
2026-11-19 17:09 ` netdev-bot+sashiko
2026-11-16 14:06 ` [PATCH net-next v8 09/10] bnge: add aRFS flow steering ndo support Vikas Gupta
2026-11-19 17:09 ` netdev-bot+sashiko
2026-11-16 14:06 ` [PATCH net-next v8 10/10] bnge: add cpu_rmap support for IRQ affinity Vikas Gupta
2026-11-19 17:09 ` 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=179510815274.3136.16405156057280346310@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