๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19284

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

#19284
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 17:09
109 lines
11674 bytes
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
Technical Details
Message-ID: <179510815274.3136.16405156057280346310@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367197-linux-kernel-netdev=dewy.ru
References: <20261116140653.1685797-11-vikas.gupta@broadcom.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367197-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179510815274.3136.16405156057280346310@kernel.org>
References: <20261116140653.1685797-11-vikas.gupta@broadcom.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2935903"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:f1xV8VPAXHafrd5bVmLWfA5ajTo= sha256:hv3xZDE5eaLJwfa1lTuzjl3ts5sRVrhYQIkOzuE2j6c=
	sha1:zMpVfgPwXWylU/JqcqTq8Bb0LzY= sha256:1G5hVnbe+pxMqtT765nOFtU0GZ43NgUfB3lvjqz7T0E=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 247AE11570B; Thu, 19 Nov 2026 20:10:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7WoyhCYVZ_iN;
	Thu, 19 Nov 2026 20:10:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367197-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 991F0115701; Thu, 19 Nov 2026 20:10:41 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 38AFB207147; Thu, 19 Nov 2026 17:10:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795108155;
	b=AOgRhV2u5aL2j34A1bs7lpmpPbh8cbizaE3SxDZoae+xb7JZAxHuuvpndDneiO3cUXY2
	 Z2qcWnY1Hd7JFar3CJxFdTUNSPdvldMrESf7IYC+/IeCPedob3hRptLcEZypaqd5VDJCi
	 pLtfJhCHQnCGPukEmeD5PZANrkgjlUIWSJLKrVX0iP/1t1yvzh40WTln7c+P+hNXzyP6a
	 DvFfDofEZVkOu3i1GLw7p6KS27O0dZFwxHprl3WKf1q2XoiH4ncVjI8aCvtO38p9wWMrw
	 NoNu167oyrEVJsCY0M0imJHjO4XfdbQSByVyjAmYuw+PrnE9ozu3uXysJPUILijixCQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795108155;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=oPTp5+Vk6QfYProopHZfzFzvz3yg3vGtC+2p3TGdMOw=;
	b=26OUChZpuZ7EyPtDTx1zwNntw+UcwEYXUZLo2vGYSEp7NMcsgJA/esnlIxeYsuRlV7fX
	 0IL3u9vWxkt2R06qjFO2pgZPZ7QmY48tkRl1IpCO6CPdJBQRhCQJKVpu7FhaO90jzfgMb
	 CfaIj3dzv4GJnTkvjBD9qkc+vazo8Z4+PxlIDxcMdAhZfM0yXsJRm/WloGjXpLXUePOTW
	 zgl3f+VL+CfjwXpvSPYXRibshpQVAFYu3e/jkVov4HMPJnJV63+404IkMR3Zbuqj3JLds
	 zQS7C6IvOHrlpXPFIOCwsU6QZJoWRjcTs4lhs80BtPCP9pDE2iD2bcS/k2roiSm+H5w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mWkz4aXx;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 27CBB606CA83;
	Thu, 19 Nov 2026 17:09:15 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mWkz4aXx
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795108154;
	b=ZlLiwarjG7XhTWRDukWeJWfTpdUbnr1Uj7il+uDPTJJytVsAkEYIkRi870tGMIER0PKV
	 V94+rhox6dzaikDhZmSGhP3d2OS3Ov/hXCx8/C9CllB+58+gRbbR6epktofvdqZOjk5GF
	 VvuqeIgPiLGbOglK1fLugbhUMyDxc0EtecCC7kjdwLGT1SVw+2VXPki/4xi6LzMFjdKp2
	 Y7AdIlTRzgpTZa8WVu7isq7JUsC8Xvh6hItso7wbyu7+iuMg0IMb994PAJojLn7cjXQjm
	 yD/fhCtcQwS3DVC1JvfWLX2Gegq0sdD1sEEzHhF7VT5ZZ+u+BZDqWqeVmjIIp9P2WIA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795108154;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=oPTp5+Vk6QfYProopHZfzFzvz3yg3vGtC+2p3TGdMOw=;
	b=a9E6YUsppv6zSdnzCGW7C1IhIyTjSHy2ez+17NRYUUI9Rl/RX3/YcaoHjACMxA9ySZi8
	 x09v2fATDyFusuU0jugp8GgtCHOpf+Q/wx3HoIyQvspVDqsSLMrTQviitMMkoZ3FyJLol
	 5BwKOdeaFshJBEzQ5WcIAojTyuZbwWhK1Uxa6lNJZKsGtScTlV+kLIq89vMTRGcpYlGPD
	 21+d5SHR2NqVY9QO6l/07NFGhcivW3k0IPiuvMQv9SnHAVERXhuXLgeOTZCgLBMsr06bI
	 gS8ZDc1xPMC8afXuL7FEDIqEpLp2xBSlfkxQEMsnS8I9T7uAvw0+fC2BI/tVPQbgG+w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mWkz4aXx;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48E1160A6F6C;
	Thu, 19 Nov 2026 17:09:14 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 282BB1F000CC;
	Thu, 19 Nov 2026 17:09:13 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795108153;
	bh=oPTp5+Vk6QfYProopHZfzFzvz3yg3vGtC+2p3TGdMOw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=mWkz4aXxT87v4e1yOXeQlOkBFoXFYWwf2xBje5f8Q60eJqs/2wgvah2tSZBC1Wbko
	 filneNcoSKdx4Vp8eYLKANhXpQPGluJvTswhCcogMgPKveIN+t6gjuX2+qmg654JJS
	 WgXCUMlJwpsdD2udPYL6cEqW9CLBbaR6pIwOSi6BSHMgQZlFsNsUfsJLCDCtTa0R99
	 F6ItYvRqiqxt+LcArh3spE3GpGKo7YOI2uuGhNBkzwIIZEfeDaRAW2vstH8urVPdyv
	 sSaoeERtgqoQMAbrSxzMvUGUbKskkBu1B95I6ukjfLnR4wZqOL0z6h1OjiB7SOCFjA
	 2lXVrDklETUzQ==
X-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
X-In-Reply-To: <20261116140653.1685797-11-vikas.gupta@broadcom.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list