From: Simon Horman <horms@kernel.org>
To: Mengyuan Lou <mengyuanlou@net-swift.com>
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
Subject: Re: [PATCH net v8 1/2] net: wangxun: protect ring accesses with RCU
Date: Tue, 24 Nov 2026 11:23:30 +0000 [thread overview]
Message-ID: <20261124112330.GI31322@horms.kernel.org> (raw)
In-Reply-To: <20261118081329.39551-2-mengyuanlou@net-swift.com>
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>
next prev parent reply other threads:[~2026-11-24 11:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 8:13 [PATCH net v8 0/2] net: wangxun: protect ring accesses with RCU Mengyuan Lou
2026-11-18 8:13 ` [PATCH net v8 1/2] " Mengyuan Lou
2026-11-22 8:33 ` netdev-bot+sashiko
2026-11-23 6:21 ` mengyuanlou
2026-11-24 11:23 ` Simon Horman [this message]
2026-11-18 8:13 ` [PATCH net v8 2/2] net: wangxun: access queue counts consistently Mengyuan Lou
2026-11-24 11:24 ` Simon Horman
2026-11-18 8:18 ` [PATCH net v8 0/2] net: wangxun: protect ring accesses with RCU netdev-bot+sinfo
2026-11-18 9:29 ` mengyuanlou
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=20261124112330.GI31322@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=duanqiangwen@net-swift.com \
--cc=edumazet@google.com \
--cc=hramamurthy@google.com \
--cc=jacob.e.keller@intel.com \
--cc=jiawenwu@trustnetic.com \
--cc=kuba@kernel.org \
--cc=linglingzhang@net-swift.com \
--cc=mengyuanlou@net-swift.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.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