Article View: linux.kernel.netdev
Article #21723Re: [PATCH net v8 1/2] net: wangxun: protect ring accesses with RCU
From: Simon Horman
Date: Tue, 24 Nov 2026 11:23
Date: Tue, 24 Nov 2026 11:23
53 lines
10667 bytes
10667 bytes
On Wed, Nov 18, 2026 at 04:13:28PM +0800, Mengyuan Lou wrote:
> In the Wangxun driver family, ring pointers in wx->rx_ring[] and
> wx->tx_ring[] can be published, cleared, or replaced during interrupt
> scheme teardown, channel reconfiguration (e.g. via ethtool -L), or TC
> setup.
>
> Various lockless readers, including stats gathering, PTP watchdogs,
> and flow control checks, access per-queue ring structures without
> formal RCU annotations. Although q_vector memory lifetime is managed
> via kfree_rcu(), the ring array accesses themselves lack explicit RCU
> dereference semantics and barriers.
>
> Annotate the ring arrays and convert their readers and writers to RCU
> primitives. Move the queue-to-register index calculation from the
> post-allocation wx_cache_ring_rss()/wx_cache_ring_vmdq() pass into per-ring
> allocation via wx_get_reg_idx(). Initialize each ring's reg_idx before
> publishing its pointer so lockless readers cannot observe an uninitialized
> value.
> Use rtnl_dereference() in control paths protected by RTNL, and RCU
> read-side critical sections for lockless readers.
>
> The ring arrays are managed by wx_alloc_q_vector() and
> wx_free_q_vector(), reached through wx_init_interrupt_scheme() and
> wx_clear_interrupt_scheme(). The probe paths call
> wx_init_interrupt_scheme() before the netdev is registered; the
> allocation path only publishes rings with rcu_assign_pointer(), so no
> RTNL is needed there. wxvf_resume() defers rebuilding the interrupt
> scheme to wxvf_reopen_subtask(), which runs under RTNL. wxvf_suspend()
> holds RTNL across wxvf_close() and wx_clear_interrupt_scheme(),
> protecting control-path readers and serializing teardown against the
> reset subtask. The service timer and work are drained before the PCI
> device is disabled.
>
> ngbe_dev_shutdown() keeps RTNL held across the WoL setup as well.
> That matches the locking of the other wx_configure_rx() callers and
> keeps the WoL configuration from racing with a channel reconfiguration,
> which re-creates the interrupt scheme. wx_clear_interrupt_scheme() has
> already zeroed the queue counts before wx_configure_rx() runs, so its
> ring loops do not access the ring arrays on this shutdown path.
>
> wx_xmit_frame() also needs to handle teardown racing with transmission:
> wx_free_q_vectors() can zero wx->num_tx_queues while the netdev remains
> registered, which could otherwise cause a modulo-by-zero, and the ring
> slot can be NULL. Bail out on either condition and account the dropped
> skb. Also account for the carrier-off path and skb_put_padto() failure;
> the latter frees the skb on error, so only the counter can be updated on
> that path.
>
> Fixes: 3f703186113f ("net: libwx: Add irq flow functions")
> Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID:
<20261124112330.GI31322@horms.kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370277-linux-kernel-netdev=dewy.ruReferences:
<20261118081329.39551-1-mengyuanlou@net-swift.com> <20261118081329.39551-2-mengyuanlou@net-swift.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370277-linux-kernel-netdev=dewy.ru From: horms@kernel.org (Simon Horman) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v8 1/2] net: wangxun: protect ring accesses with RCU Date: Tue, 24 Nov 2026 11:23:30 +0000 Organization: Usenet Network Message-ID: <20261124112330.GI31322@horms.kernel.org> References: <20261118081329.39551-1-mengyuanlou@net-swift.com> <20261118081329.39551-2-mengyuanlou@net-swift.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="4122851"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:TK7vxEzp+uGGeqdUk06NDC7YzsQ= sha256:hlrTILypGS2RsC06/yE6aVvtlEww44KCj6mmmJmWEWU= sha1:ev3PeKNCOZ+ELA2JtEck1/2co/4= sha256:8D/XrK7vYa7ipPrRE4gSMiylkVFtv48bT3GN4bi7y8I= Content-Disposition: inline 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 C8742125DFF; Tue, 24 Nov 2026 14:23:54 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 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] 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 3H0qEHzljIfG; Tue, 24 Nov 2026 14:23:51 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370277-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 04E68125DFD; Tue, 24 Nov 2026 14:23: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 C1DA635DA1; Tue, 24 Nov 2026 11:23:39 +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=1795519417; b=gtnvROL0kRYgJjNtWh14/r9HvibkDpzmIHcjshLGFkTeow0NX8zT4D5i38FrNOwyRErU mOR20Nf/WI1VbijTEv0lNQ+5JYsartNoLOBbu1PqgFlN9oQ9Yw20xI5KGFk3q1b6VbeNT DWlOQM1+msMgQjbqHqvLicWG+JK5EfH/DVy+y4e6D7vm+ajSrUCck5m37rOsVbAEbQeko HrPthfhKerShE0IFsh7E5PS5a+iquM569Th1MfsFb0NX0OpGCeI4RzSW8qMWiy4hh3twT nTg67QABEfmcuc7aOzOhXrWIvyODiGtD8CklTOHoGY0RrL9KevWkVYPbrpHvoWvXLOQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795519417; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=DgIESJx/OzNSi+XE4Kpwkpt4Xh11qzjNFJ3vOR9mBNE=; b=ro4t0OlMvPpjdyp8OnfX0By7enX2saScjlS4t7XN8vfFJscQzBxrorOQm58LvmcwIWbE DqQUphqhN6PDBJGSNmTJFwqnDPZFHtsyoOkixNiGcBW2MS2SO9J1LMc/pbEdU0HNjirvI bgg4P0GZETM4QbBEZ4kTVPcYf2u6H7hvtcyUbqSanAOxZzyQPFg+Fj7nAjwNZmCHQca6m HUC+W8kWymMM0Fb/GdZ1VP+Ap6JbXVg2/igxQeApWGFpdWVaMbo5LUTchphA3NEdy8SQV n7UVhqgtG/vxEi1Des2YsWply8S/j4f7kxjdFFFrLkF9b9uD0Xlzzblfv0/i0MLysEA== 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=Baw1Jfta; 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 7575F606A32D; Tue, 24 Nov 2026 11:23:37 +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=Baw1Jfta 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=1795519416; b=mVG+XHydMqrHYmQNRAzikKX1NxfxjI3vGEQr3aOncJ8gPiGsKJiCa8m0K/KsK56Y1K7d wNiXyLa8pau8Q3lum2rL4wS0PT1VX5mesUXou7fRrDF56hZjnlCK8LAzZ7YmP6SGHbt5g 9FpSvrARgRPFFv1bYR2YEoDWKI6JbQ+7nyYOEYr8JtynxWg58BviYaYAy8jfE5gQsq9Se T7HN1vWsohrScd1zcdF6veqyTUX2hHAf/ijtx/TQEfYNDphOzUMSlPvgfALtr+2CzUWHW fbWoDOmiWZGF0FGFlk/ZE21o0vjYRVw9D3XEHvH2D3iD9XLG0jyFuI+1EblSA3H4iww== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795519416; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=DgIESJx/OzNSi+XE4Kpwkpt4Xh11qzjNFJ3vOR9mBNE=; b=hGmYq5byaisxT2gGgATiwJWPIqLvcutAhkNdeXvVdwdBAq25TPH40Is7XrQ2aYM3jQSK VzEin5W1Vb84AfBawpD+yxUdsCODyScGdVzuUTkP0bt1bhzLa5qTNO38yIsyOqCXw7JJA Nd6RjFCt2hKLLl52mvTe/W5KzabUyCj5RwVGTKpEIylK4vhWDSoHn/feXKuRhFOGz71Ry E2Sfm8Y0rCKTCw8wuLbtmdg1jFdfX3q68WGD+6z/PpmwTfFAVqc0C31dHrcLd6d0g85lV syxzc2kdqDBuS1kU5iAVCOax4HhewtSUokyFezBl81HZEcyhTqXbgGY8+PQAINntcjg== 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=Baw1Jfta; 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 90D48606A31E for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 11:23:36 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82CB41F000C4; Tue, 24 Nov 2026 11:23:33 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795519415; bh=DgIESJx/OzNSi+XE4Kpwkpt4Xh11qzjNFJ3vOR9mBNE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Baw1Jftaikr/WrOzMwe/s65Q1RJJZPRnm0ndgukey6IUwYscpgglnrDkHYy3cYXBX CNp6pZqvuvgyIvpzfcPenetFWWF/MEK376SnDKGOW6s91lyn2taaeKSkDbZbBFMpDJ A6/oKA1uF/PfDg6ZHQ3Jkb6njcRjxpuIH41gu6J7EHjwEGcd6f2uBjIfiIp9pB43xI fg1XSrRC0cjBEThzMXhHZt0F8wdOpRRhm2bAbyqb0wYBJpQeWmNskeWRFlyiutPa0t f1uFR7u1PG6mu7Hps2ElG8FPQRuO4tneQba80zdKzoz3XxUqmhu7O24TjiQF8bJciu s5s0KkTnBx4BQ== X-Cc: netdev@vger.kernel.org, jiawenwu@trustnetic.com, duanqiangwen@net-swift.com, linglingzhang@net-swift.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, hramamurthy@google.com, jacob.e.keller@intel.com, przemyslaw.kitszel@intel.com 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 X-In-Reply-To: <20261118081329.39551-2-mengyuanlou@net-swift.com>