From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795956411; b=GoeLMw2vyOlxHwySQ8oShiH1QfGTtje9EwNJqXXLvwpmZfkiXWsShqU3ItgwdUU9VF20 AuDcMTH6DJ8c11oOWQj/3sBeUVM/7tETCeYg9fJlUIRuQvxw3LTCMmo2jf1ucM7QhqqnQ 28zS8fQN7g/3OjqzBaHIBsjHsUiYiKst8XgfaBsYyrYdrRd87P07OPbk2vQhT5I9UUjbG 7kqeuyvi6opmaS+uf0Am/dbNrHD1q6mFYq8jaATK9L0+7tUpiEM0Rr2H6r67ffmU1FoSe SwoXPA0K+9lTddgupc1t4Mtdt3X+uumIP9B/r9DC2fuH1xAkH8CPqiQ5+dJJYtorrbw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795956411; 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=VW/eXYWLLPmQlrGFsh1P3LlOUlWYI6XawYe3DEuNBi8=; b=M47REjTcQS1hHTY5x8HjLfagNBHBNTTM8HfHR9vEgi/TBTBoKhwNRmmtwh9zEd6CdeEH N48hERm1ha+l37ON/5PQXV0Jr+2Amc7OrU7jSWPDoIadBG8OeR1a2+TqDpib76K4WJkg7 gp/tWlGMeSB3H3HBuYfQDfVXVnT9Ra4u5JoSUAp3roPmMQPDVzwRJ6BKFoTQWTnqwIMbV zn3b+Ax04MiU0eG14pyq6LltWtkAmxwBMgGvKhRGOyTtE2h3r4FO1sYOZKh/sa1lDUIfY ZUDipiQLA2fkm9FJF+44yGEna4Hd4ZkyPfI+IzcARjIdPfdHHjPU2lS8Rper+hxllww== 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=efynjgDO; arc=none smtp.remote-ip=100.103.45.18 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 5FFDD606A686; Sun, 29 Nov 2026 12:46:51 +0000 (UTC) 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=efynjgDO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 395E51F00898; Sun, 29 Nov 2026 12:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795956411; bh=VW/eXYWLLPmQlrGFsh1P3LlOUlWYI6XawYe3DEuNBi8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=efynjgDOArUY7XU1X98Qdu4EipDmWnZfWyqsdL798zhmdIJ3VQO74M63z6hCcYcum RpIKApeumaaVgQiZ3deE4Kp7OM2c6PgMzBPcHqIAWtnRqg/oJ2hzcmom039k2rPBRD 6GU8QdD1wZflssZZHFSzVcX+d4FQKTVJrAepInMr/i6mr2aju8ubRnhVEl3ZiVxsHV 6PIApzYTVJTEM0d/0/KcwF4iUwFGBQnAa62AEh3j2bRglpCQG8Sjvv9Sc9VUeukRSJ IftVEhPikvb99FZw3XCMxUfUXfC3YATqzThEK5gSpcJLaBEatUAptkQpxGhbgZhiUG 5UfT6CtciMUkw== Subject: Re: [PATCH net-next v10 10/10] bnge: add cpu_rmap support for IRQ affinity 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 Date: Sun, 29 Nov 2026 12:46:49 +0000 Message-ID: <179595640978.3146.2248814989251776899@kernel.org> In-Reply-To: <20261125115434.2080590-11-vikas.gupta@broadcom.com> References: <20261125115434.2080590-11-vikas.gupta@broadcom.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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