net: wangxun: protect ring accesses with RCU
Subsystems (3)
Mengyuan Lou
maintainerv8 cover net: wangxun: protect ring accesses with RCU
This series protects Wangxun ring-array accesses during interrupt-scheme reconfiguration.
Patch 1 converts ring-pointer access to RCU and initializes reg_idx before publishing each ring. Patch 2 pairs lockless queue-count reads and writes so readers remain safe while queue vectors are torn down or rebuilt.
Changelog:
v8:
- Split queue-count access updates into a separate patch.
- Initialize reg_idx before ring publication while preserving RSS/VMDQ queue-to-register mapping.
- Pair lockless queue-count reads and writes across setup, teardown, allocation-error handling, and VF queue setup.
v7: https://lore.kernel.org/all/[email protected]/
Mengyuan Lou (2):
net: wangxun: protect ring accesses with RCU
net: wangxun: access queue counts consistently
drivers/net/ethernet/wangxun/libwx/wx_err.c | 25 ++- .../net/ethernet/wangxun/libwx/wx_ethtool.c | 10 +- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 90 +++++++--- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 164 ++++++++---------- drivers/net/ethernet/wangxun/libwx/wx_ptp.c | 11 +- drivers/net/ethernet/wangxun/libwx/wx_type.h | 12 +- .../net/ethernet/wangxun/libwx/wx_vf_common.c | 2 +- .../net/ethernet/wangxun/libwx/wx_vf_lib.c | 7 +- .../net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 4 +- drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 11 +- .../net/ethernet/wangxun/ngbevf/ngbevf_main.c | 4 +- .../ethernet/wangxun/txgbe/txgbe_ethtool.c | 6 +- .../net/ethernet/wangxun/txgbe/txgbe_fdir.c | 2 +- .../net/ethernet/wangxun/txgbe/txgbe_main.c | 4 +- .../ethernet/wangxun/txgbevf/txgbevf_main.c | 10 +- 15 files changed, 215 insertions(+), 147 deletions(-)
Signature · 1 line
2.30.1
Mengyuan Lou
maintainerPATCH v8 1/2 net: wangxun: protect ring accesses with RCU
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.
--- drivers/net/ethernet/wangxun/libwx/wx_err.c | 20 ++- .../net/ethernet/wangxun/libwx/wx_ethtool.c | 10 +- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 73 ++++++++-- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 137 ++++++++---------- drivers/net/ethernet/wangxun/libwx/wx_ptp.c | 6 +- drivers/net/ethernet/wangxun/libwx/wx_type.h | 12 +- .../net/ethernet/wangxun/libwx/wx_vf_common.c | 2 +- .../net/ethernet/wangxun/libwx/wx_vf_lib.c | 7 +- .../net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 4 +- drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 11 +- .../ethernet/wangxun/txgbe/txgbe_ethtool.c | 6 +- .../net/ethernet/wangxun/txgbe/txgbe_fdir.c | 2 +- .../net/ethernet/wangxun/txgbe/txgbe_main.c | 4 +- 13 files changed, 174 insertions(+), 120 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_err.c +16 -4
@@ -201,12 +201,18 @@ static bool wx_ring_tx_pending(struct wx *wx) {int i; +rcu_read_lock ();for (i =0 ; i < wx->num_tx_queues; i++) { -struct wx_ring *tx_ring = wx->tx_ring[i]; +struct wx_ring *tx_ring =rcu_dereference (wx->tx_ring[i]); -if (tx_ring->next_to_use != tx_ring->next_to_clean) +if (!tx_ring) +continue ; +if (tx_ring->next_to_use != tx_ring->next_to_clean) { +rcu_read_unlock ();return true; + } } +rcu_read_unlock ();return false; }
@@ -264,8 +270,14 @@ static void wx_detect_tx_hang(struct wx *wx)/* Force detection of hung controller */ if (netif_carrier_ok (wx->netdev)) { -for (i =0 ; i < wx->num_tx_queues; i++) -set_bit (WX_TX_DETECT_HANG , wx->tx_ring[i]->state); +rcu_read_lock (); +for (i =0 ; i < wx->num_tx_queues; i++) { +struct wx_ring *tx_ring =rcu_dereference (wx->tx_ring[i]); + +if (tx_ring) +set_bit (WX_TX_DETECT_HANG , tx_ring->state); + } +rcu_read_unlock (); } }
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c +6 -4
@@ -154,8 +154,9 @@ void wx_get_ethtool_stats(struct net_device *netdev, } } +rcu_read_lock ();for (j =0 ; j < netdev->num_tx_queues; j++) { - ring = wx->tx_ring[j]; + ring =rcu_dereference (wx->tx_ring[j]);if (!ring) { data[i++] =0 ; data[i++] =0 ;
@@ -170,7 +171,7 @@ void wx_get_ethtool_stats(struct net_device *netdev, i +=2 ; }for (j =0 ; j <WX_NUM_RX_QUEUES ; j++) { - ring = wx->rx_ring[j]; + ring =rcu_dereference (wx->rx_ring[j]);if (!ring) { data[i++] =0 ; data[i++] =0 ;
@@ -184,6 +185,7 @@ void wx_get_ethtool_stats(struct net_device *netdev, }while (u64_stats_fetch_retry (&ring->syncp, start)); i +=2 ; } +rcu_read_unlock (); }EXPORT_SYMBOL (wx_get_ethtool_stats);
@@ -805,9 +807,9 @@ static int wx_set_ringparam_vf(struct net_device *netdev,if (!netif_running (wx->netdev)) {for (i =0 ; i < wx->num_tx_queues; i++) - wx->tx_ring[i]->count = new_tx_count; +rtnl_dereference (wx->tx_ring[i])->count = new_tx_count;for (i =0 ; i < wx->num_rx_queues; i++) - wx->rx_ring[i]->count = new_rx_count; +rtnl_dereference (wx->rx_ring[i])->count = new_rx_count; wx->tx_ring_count = new_tx_count; wx->rx_ring_count = new_rx_count;
drivers/net/ethernet/wangxun/libwx/wx_hw.c +57 -16
143 lines not on this page · raw message
drivers/net/ethernet/wangxun/libwx/wx_lib.c +58 -79
286 lines not on this page · raw message
drivers/net/ethernet/wangxun/libwx/wx_ptp.c +5 -1
@@ -311,11 +311,15 @@ static void wx_ptp_rx_hang(struct wx *wx)/* determine the most recent watchdog or rx_timestamp event */ rx_event = wx->last_rx_ptp_check; +rcu_read_lock ();for (n =0 ; n < wx->num_rx_queues; n++) { - rx_ring = wx->rx_ring[n]; + rx_ring =rcu_dereference (wx->rx_ring[n]); +if (!rx_ring) +continue ;if (time_after (rx_ring->last_rx_timestamp, rx_event)) rx_event = rx_ring->last_rx_timestamp; } +rcu_read_unlock ();/* only need to read the high RXSTMP register to clear the lock */ if (time_is_before_jiffies (rx_event +5 *HZ )) {
drivers/net/ethernet/wangxun/libwx/wx_type.h +10 -2
@@ -1359,8 +1359,16 @@ struct wx {u32 tx_ring_count;u32 rx_ring_count; -struct wx_ring *tx_ring[64 ]____cacheline_aligned_in_smp ; -struct wx_ring *rx_ring[64 ]; +/* Ring pointers are published and cleared by the interrupt scheme +* setup and teardown paths with RCU pointer operations. Control-path +* readers use rtnl_dereference() while holding RTNL. Lockless readers +* (such as xmit, stats, and watchdog paths) must use rcu_dereference() +* inside an RCU read-side critical section and NULL-check the result. +* RCU protects pointer lifetime; fields initialized after publication +* need their own ordering guarantees. +*/ +struct wx_ring __rcu *tx_ring[64 ]____cacheline_aligned_in_smp ; +struct wx_ring __rcu *rx_ring[64 ];struct wx_q_vector *q_vector[64 ];int num_rx_pools;int num_rx_queues_per_pool;
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c +1 -1
@@ -205,7 +205,7 @@ static void wx_configure_rx_vf(struct wx *wx)* the Base and Length of the Rx Descriptor Ring */ for (i =0 ; i < wx->num_rx_queues; i++) { -struct wx_ring *rx_ring = wx->rx_ring[i]; +struct wx_ring *rx_ring =rtnl_dereference (wx->rx_ring[i]);#ifdef HAVE_SWIOTLB_SKIP_CPU_SYNC wx_set_rx_buffer_len_vf (wx, rx_ring);#endif
drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c +5 -2
@@ -175,8 +175,11 @@ void wx_configure_tx_vf(struct wx *wx)u32 i;/* Setup the HW Tx Head and Tail descriptor pointers */ -for (i =0 ; i < wx->num_tx_queues; i++) -wx_configure_tx_ring_vf (wx, wx->tx_ring[i]); +for (i =0 ; i < wx->num_tx_queues; i++) { +struct wx_ring *tx_ring =rtnl_dereference (wx->tx_ring[i]); + +wx_configure_tx_ring_vf (wx, tx_ring); + } } static void wx_configure_srrctl_vf(struct wx *wx, struct wx_ring *ring,
drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +2 -2
@@ -37,9 +37,9 @@ static int ngbe_set_ringparam(struct net_device *netdev,if (!netif_running (wx->netdev)) {for (i =0 ; i < wx->num_tx_queues; i++) - wx->tx_ring[i]->count = new_tx_count; +rtnl_dereference (wx->tx_ring[i])->count = new_tx_count;for (i =0 ; i < wx->num_rx_queues; i++) - wx->rx_ring[i]->count = new_rx_count; +rtnl_dereference (wx->rx_ring[i])->count = new_rx_count; wx->tx_ring_count = new_tx_count; wx->rx_ring_count = new_rx_count;
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +8 -3
@@ -406,7 +406,7 @@ static void ngbe_disable_device(struct wx *wx)/* disable all enabled rx queues */ for (i =0 ; i < wx->num_rx_queues; i++)/* this call also flushes the previous write */ -wx_disable_rx_queue (wx, wx->rx_ring[i]); +wx_disable_rx_queue (wx,rtnl_dereference (wx->rx_ring[i]));/* disable receives */ wx_disable_rx (wx);wx_napi_disable_all (wx);
@@ -422,7 +422,7 @@ static void ngbe_disable_device(struct wx *wx)wx_irq_disable (wx);/* disable transmits in the hardware now that interrupts are off */ for (i =0 ; i < wx->num_tx_queues; i++) { -u8 reg_idx = wx->tx_ring[i]->reg_idx; +u8 reg_idx =rtnl_dereference (wx->tx_ring[i])->reg_idx;wr32 (wx,WX_PX_TR_CFG (reg_idx),WX_PX_TR_CFG_SWFLSH ); }
@@ -580,8 +580,11 @@ static void ngbe_dev_shutdown(struct pci_dev *pdev, bool *enable_wake)if (netif_running (netdev))ngbe_close (netdev);wx_clear_interrupt_scheme (wx); -rtnl_unlock (); +/* Keep RTNL held across the WoL setup so wx_configure_rx() runs under +* the same lock as its other callers, and cannot race with a channel +* reconfiguration. +*/ if (wufc) {wx_set_rx_mode (netdev);wx_configure_rx (wx);
@@ -589,6 +592,8 @@ static void ngbe_dev_shutdown(struct pci_dev *pdev, bool *enable_wake) }else {wr32 (wx,WX_PSR_WKUP_CTL ,0 ); } +rtnl_unlock (); +pci_wake_from_d3 (pdev, !!wufc); *enable_wake = !!wufc;wx_control_hw (wx, false);
drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c +3 -3
@@ -61,9 +61,9 @@ static int txgbe_set_ringparam(struct net_device *netdev,if (!netif_running (wx->netdev)) {for (i =0 ; i < wx->num_tx_queues; i++) - wx->tx_ring[i]->count = new_tx_count; +rtnl_dereference (wx->tx_ring[i])->count = new_tx_count;for (i =0 ; i < wx->num_rx_queues; i++) - wx->rx_ring[i]->count = new_rx_count; +rtnl_dereference (wx->rx_ring[i])->count = new_rx_count; wx->tx_ring_count = new_tx_count; wx->rx_ring_count = new_rx_count;
@@ -366,7 +366,7 @@ static int txgbe_add_ethtool_fdir_entry(struct txgbe *txgbe,/* Map the ring onto the absolute queue index */ if (!vf) - queue = wx->rx_ring[ring]->reg_idx; + queue =rtnl_dereference (wx->rx_ring[ring])->reg_idx;else queue = ((vf -1 ) * wx->num_rx_queues_per_pool) + ring; }
drivers/net/ethernet/wangxun/txgbe/txgbe_fdir.c +1 -1
@@ -606,7 +606,7 @@ static void txgbe_fdir_filter_restore(struct wx *wx)/* Map the ring onto the absolute queue index */ if (!vf) - queue = wx->rx_ring[ring]->reg_idx; + queue =rtnl_dereference (wx->rx_ring[ring])->reg_idx;else queue = ((vf -1 ) * wx->num_rx_queues_per_pool) + ring; }
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +2 -2
@@ -239,7 +239,7 @@ static void txgbe_disable_device(struct wx *wx)/* disable all enabled rx queues */ for (i =0 ; i < wx->num_rx_queues; i++)/* this call also flushes the previous write */ -wx_disable_rx_queue (wx, wx->rx_ring[i]); +wx_disable_rx_queue (wx,rtnl_dereference (wx->rx_ring[i]));netif_tx_stop_all_queues (netdev);netif_tx_disable (netdev);
@@ -275,7 +275,7 @@ static void txgbe_disable_device(struct wx *wx)/* disable transmits in the hardware now that interrupts are off */ for (i =0 ; i < wx->num_tx_queues; i++) { -u8 reg_idx = wx->tx_ring[i]->reg_idx; +u8 reg_idx =rtnl_dereference (wx->tx_ring[i])->reg_idx;wr32 (wx,WX_PX_TR_CFG (reg_idx),WX_PX_TR_CFG_SWFLSH ); }
Signature · 1 line
2.30.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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] The commit message describes VF suspend/resume changes that are not in the patch, and relies on them to argue that the new __rcu /…
--
net: wangxun: protect ring accesses with RCU
This commit marks wx->tx_ring[] and wx->rx_ring[] as __rcu. Readers are converted to rcu_dereference() or rtnl_dereference(). The reg_idx computation moves into per-ring allocation via wx_get_reg_idx(), and wx_xmit_frame() gains checks for a NULL ring or zero queue count during teardown.
Quoted 11 lines
The ring arrays are managed by
wx_alloc_q_vector()andwx_free_q_vector(), reached throughwx_init_interrupt_scheme()andwx_clear_interrupt_scheme(). The probe paths callwx_init_interrupt_scheme()before the netdev is registered; the allocation path only publishes rings withrcu_assign_pointer(), so no RTNL is needed there.wxvf_resume()defers rebuilding the interrupt scheme towxvf_reopen_subtask(), which runs under RTNL.wxvf_suspend()holds RTNL acrosswxvf_close()andwx_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.
[Severity: High]
Is a VF hunk missing from this patch, or does this paragraph describe a different revision?
The only change to wx_vf_common.c here is the rtnl_dereference() conversion in wx_configure_rx_vf(). wxvf_reopen_subtask() does not exist anywhere under drivers/net/ethernet/wangxun/. After this patch, wxvf_suspend() (which wxvf_shutdown() also calls) and wxvf_resume() still read:
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c:wxvf_suspend() {
netif_device_detach(wx->netdev);
wx_clear_interrupt_scheme(wx);
pci_disable_device(pdev);
}drivers/net/ethernet/wangxun/libwx/wx_vf_common.c:wxvf_resume() {
pci_set_master(pdev);
wx_init_interrupt_scheme(wx);
netif_device_attach(wx->netdev);
}So wxvf_suspend() takes no RTNL and does not call wxvf_close() on a running interface. It also does not set WX_STATE_DOWN and does not cancel service_timer or service_task.
The new comment in struct wx says:
Control-path readers use rtnl_dereference() while holding RTNL.
That only works if the writers in wx_free_q_vector() also hold RTNL. On this path, wx_free_q_vectors() zeroes the queue counts, NULLs each slot, and calls kfree_rcu() on the q_vector that embeds the rings, all without RTNL.
Can the service task race with this? Suspend leaves the timer armed and WX_STATE_DOWN clear, so the check in wxvf_reset_subtask() still passes:
wxvf_service_task()
wxvf_reset_subtask()
rtnl_lock()
wxvf_reinit_locked()
wxvf_down()
wx_clean_all_tx_rings()
wx_clean_all_rx_rings()
wx_configure_vf()
wx_configure_tx_vf()
wx_configure_rx_vf()wx_set_ringparam_vf() is another example:
rtnl_dereference(wx->tx_ring[i])->count = new_tx_count;
None of these readers check for NULL or run inside an RCU read-side section, and some of them sleep, e.g. read_poll_timeout(). Could they dereference a NULL ring, or use a ring after its kfree_rcu() grace period has ended?
On resume, wx_init_interrupt_scheme() publishes new zeroed rings with tx_buffer_info == NULL and desc == NULL, and sets WX_STATE_DOWN. Nothing reopens the device after that. netif_device_attach() then wakes the TX queues of a netdev that is still running, and its carrier was never turned off.
The new checks in wx_xmit_frame() pass, because num_tx_queues is non-zero and the ring is non-NULL. Does wx_xmit_frame_ring() then dereference a NULL tx_buffer_info here?
first = &tx_ring->tx_buffer_info[tx_ring->next_to_use];
first->skb = skb;Because suspend skips wxvf_close(), the queue and misc IRQs are not freed before pci_free_irq_vectors(). NAPI instances that are still enabled are passed to netif_napi_del(). The descriptor DMA memory, the buffer_info arrays and the page_pool are reachable only through the rings freed by kfree_rcu(). Do these leak on every suspend or shutdown with the interface up?
Much of this VF lifecycle behaviour predates the patch. However, the commit message depends on the RTNL, close, drain and reopen changes to justify the rtnl_dereference() locking model, and those changes are not in the patch. Could the missing VF changes be included, or could the commit message and the struct wx comment be corrected to match the locking the code actually has?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118081329.39551-1-mengyuanlou%40net-swift.com
[email protected]
maintainerQuoted 9 lines
2026年11月22日 16:33,[email protected] 写道:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
Quoted 8 lines
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] The commit message describes VF suspend/resume changes that are not in the patch, and relies on them to argue that the new
__rcu/…
The commit about vf resume/suspend related commit, just merged into net-next, but not yet merged into net.
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?h=main&id=a6c3e4c1f7032e44cf5dc897a3d328b138e770d1
Quoted 112 lines
--
net: wangxun: protect ring accesses with RCU
This commit marks wx->tx_ring[] and wx->rx_ring[] as
__rcu. Readers are converted torcu_dereference()orrtnl_dereference(). Thereg_idxcomputation moves into per-ring allocation viawx_get_reg_idx(), andwx_xmit_frame()gains checks for a NULL ring or zero queue count during teardown.Quoted 11 lines
The ring arrays are managed by
wx_alloc_q_vector()andwx_free_q_vector(), reached throughwx_init_interrupt_scheme()andwx_clear_interrupt_scheme(). The probe paths callwx_init_interrupt_scheme()before the netdev is registered; the allocation path only publishes rings withrcu_assign_pointer(), so no RTNL is needed there.wxvf_resume()defers rebuilding the interrupt scheme towxvf_reopen_subtask(), which runs under RTNL.wxvf_suspend()holds RTNL acrosswxvf_close()andwx_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.[Severity: High]
Is a VF hunk missing from this patch, or does this paragraph describe a different revision?
The only change to
wx_vf_common.chere is thertnl_dereference()conversion inwx_configure_rx_vf().wxvf_reopen_subtask()does not exist anywhere underdrivers/net/ethernet/wangxun/. After this patch,wxvf_suspend()(whichwxvf_shutdown()also calls) andwxvf_resume()still read:drivers/net/ethernet/wangxun/libwx/wx_vf_common.c:wxvf_suspend() { netif_device_detach(wx->netdev); wx_clear_interrupt_scheme(wx); pci_disable_device(pdev); }drivers/net/ethernet/wangxun/libwx/wx_vf_common.c:wxvf_resume() { pci_set_master(pdev); wx_init_interrupt_scheme(wx); netif_device_attach(wx->netdev); }So
wxvf_suspend()takes no RTNL and does not callwxvf_close()on a running interface. It also does not setWX_STATE_DOWNand does not cancelservice_timerorservice_task.The new comment in struct wx says:
Control-path readers use
rtnl_dereference()while holding RTNL.That only works if the writers in
wx_free_q_vector()also hold RTNL. On this path,wx_free_q_vectors()zeroes the queue counts, NULLs each slot, and callskfree_rcu()on theq_vectorthat embeds the rings, all without RTNL.Can the service task race with this? Suspend leaves the timer armed and
WX_STATE_DOWNclear, so the check inwxvf_reset_subtask()still passes:
wxvf_service_task()
wxvf_reset_subtask()
rtnl_lock()
wxvf_reinit_locked()wxvf_down() wx_clean_all_tx_rings() wx_clean_all_rx_rings() wx_configure_vf() wx_configure_tx_vf() wx_configure_rx_vf()
wx_set_ringparam_vf()is another example:rtnl_dereference(wx->tx_ring[i])->count = new_tx_count;None of these readers check for NULL or run inside an RCU read-side section, and some of them sleep, e.g.
read_poll_timeout(). Could they dereference a NULL ring, or use a ring after itskfree_rcu()grace period has ended?On resume,
wx_init_interrupt_scheme()publishes new zeroed rings withtx_buffer_info== NULL and desc == NULL, and setsWX_STATE_DOWN. Nothing reopens the device after that.netif_device_attach()then wakes the TX queues of a netdev that is still running, and its carrier was never turned off.The new checks in
wx_xmit_frame()pass, becausenum_tx_queuesis non-zero and the ring is non-NULL. Doeswx_xmit_frame_ring()then dereference a NULLtx_buffer_infohere?first = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; first->skb = skb;Because suspend skips
wxvf_close(), the queue and misc IRQs are not freed beforepci_free_irq_vectors(). NAPI instances that are still enabled are passed tonetif_napi_del(). The descriptor DMA memory, thebuffer_infoarrays and thepage_poolare reachable only through the rings freed bykfree_rcu(). Do these leak on every suspend or shutdown with the interface up?Much of this VF lifecycle behaviour predates the patch. However, the commit message depends on the RTNL, close, drain and reopen changes to justify the
rtnl_dereference()locking model, and those changes are not in the patch. Could the missing VF changes be included, or could the commit message and the struct wx comment be corrected to match the locking the code actually has?Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118081329.39551-1-mengyuanlou%40net-swift.com
Paolo Abeni
maintainerQuoted 13 lines · On 11/23/26 07:21, [email protected] wrote:
Quoted 13 lines
2026年11月22日 16:33,[email protected] 写道:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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).
Quoted 6 lines
Quoted 2 lines
- [High] The commit message describes VF suspend/resume changes that are not in the patch, and relies on them to argue that the new
__rcu/…The commit about vf resume/suspend related commit, just merged into net-next, but not yet merged into net.
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?h=main&id=a6c3e4c1f7032e44cf5dc897a3d328b138e770d1
Meaning even this series must go via the 'net-next' tree.
/P
Quoted 47 lines · Mengyuan Lou
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_vectormemory lifetime is managed viakfree_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'sreg_idxbefore publishing its pointer so lockless readers cannot observe an uninitialized value.
Usertnl_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()andwx_free_q_vector(), reached throughwx_init_interrupt_scheme()andwx_clear_interrupt_scheme(). The probe paths callwx_init_interrupt_scheme()before the netdev is registered; the allocation path only publishes rings withrcu_assign_pointer(), so no RTNL is needed there.wxvf_resume()defers rebuilding the interrupt scheme towxvf_reopen_subtask(), which runs under RTNL.wxvf_suspend()holds RTNL acrosswxvf_close()andwx_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 otherwx_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 beforewx_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 zerowx->num_tx_queueswhile 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 andskb_put_padto()failure; the latter frees the skb on error, so only the counter can be updated on that path.
Quoted 2 lines
Fixes 3f703186113f ("net: libwx: Add irq flow functions")Signed-off-by Mengyuan Lou <[email protected]>
Mengyuan Lou
maintainerPATCH v8 2/2 net: wangxun: access queue counts consistently
In reply to Mengyuan LouQueue-vector teardown clears wx->num_tx_queues and wx->num_rx_queues while the netdev can remain registered. Lockless readers may use these counts as ring-array loop bounds while teardown is clearing the ring slots. wx_xmit_frame() also uses the Tx count to select a ring and must not divide by zero during teardown.
Use READ_ONCE() to take a single count snapshot in the lockless readers, and use WRITE_ONCE() for queue-count updates during scheme setup, teardown, and allocation-error handling, including the VF queue setup callbacks. Keep the existing NULL checks so a reader that observed an old non-zero count can safely skip ring slots that have since been cleared. wx_xmit_frame() retains its zero-count guard before queue-index modulo.
--- drivers/net/ethernet/wangxun/libwx/wx_err.c | 7 +++-- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 23 ++++++++++----- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 29 ++++++++++--------- drivers/net/ethernet/wangxun/libwx/wx_ptp.c | 5 ++-- .../net/ethernet/wangxun/ngbevf/ngbevf_main.c | 4 +-- .../ethernet/wangxun/txgbevf/txgbevf_main.c | 10 +++---- 6 files changed, 46 insertions(+), 32 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_err.c +5 -2
@@ -199,10 +199,11 @@ EXPORT_SYMBOL(wx_init_err_task);static bool wx_ring_tx_pending (struct wx *wx) { +int num_tx_queues =READ_ONCE (wx->num_tx_queues);int i;rcu_read_lock (); -for (i =0 ; i < wx->num_tx_queues; i++) { +for (i =0 ; i < num_tx_queues; i++) {struct wx_ring *tx_ring =rcu_dereference (wx->tx_ring[i]);if (!tx_ring)
@@ -261,6 +262,7 @@ static void wx_watchdog_flush_tx(struct wx *wx)static void wx_detect_tx_hang (struct wx *wx) { +int num_tx_queues;int i;/* If we're down or resetting, just bail */
@@ -270,8 +272,9 @@ static void wx_detect_tx_hang(struct wx *wx)/* Force detection of hung controller */ if (netif_carrier_ok (wx->netdev)) { + num_tx_queues =READ_ONCE (wx->num_tx_queues);rcu_read_lock (); -for (i =0 ; i < wx->num_tx_queues; i++) { +for (i =0 ; i < num_tx_queues; i++) {struct wx_ring *tx_ring =rcu_dereference (wx->tx_ring[i]);if (tx_ring)
drivers/net/ethernet/wangxun/libwx/wx_hw.c +15 -8
@@ -1596,10 +1596,11 @@ EXPORT_SYMBOL(wx_enable_sec_rx_path);static void wx_vlan_strip_control (struct wx *wx,bool enable) { +int num_rx_queues =READ_ONCE (wx->num_rx_queues);int i, j;rcu_read_lock (); -for (i =0 ; i < wx->num_rx_queues; i++) { +for (i =0 ; i < num_rx_queues; i++) {struct wx_ring *ring =rcu_dereference (wx->rx_ring[i]);if (!ring)
@@ -2777,6 +2778,7 @@ static void wx_disable_rx_drop(struct wx *wx, struct wx_ring *ring)int wx_fc_enable (struct wx *wx,bool tx_pause,bool rx_pause) { +int num_rx_queues =READ_ONCE (wx->num_rx_queues);u16 pause_time =WX_DEFAULT_FCPAUSE ;u32 mflcn_reg, fccfg_reg, reg;u32 fcrtl, fcrth;
@@ -2849,8 +2851,8 @@ int wx_fc_enable(struct wx *wx, bool tx_pause, bool rx_pause)* and performance reasons. */ rcu_read_lock (); -if (wx->num_rx_queues >1 && !tx_pause) { -for (i =0 ; i < wx->num_rx_queues; i++) { +if (num_rx_queues >1 && !tx_pause) { +for (i =0 ; i < num_rx_queues; i++) {struct wx_ring *rx_ring =rcu_dereference (wx->rx_ring[i]);if (!rx_ring)
@@ -2858,7 +2860,7 @@ int wx_fc_enable(struct wx *wx, bool tx_pause, bool rx_pause)wx_enable_rx_drop (wx, rx_ring); } }else { -for (i =0 ; i < wx->num_rx_queues; i++) { +for (i =0 ; i < num_rx_queues; i++) {struct wx_ring *rx_ring =rcu_dereference (wx->rx_ring[i]);if (!rx_ring)
@@ -2875,6 +2877,7 @@ EXPORT_SYMBOL(wx_fc_enable);static void wx_update_xoff_rx_lfc (struct wx *wx) {struct wx_hw_stats *hwstats = &wx->stats; +int num_tx_queues;u64 data;int i;
@@ -2893,8 +2896,9 @@ static void wx_update_xoff_rx_lfc(struct wx *wx)if (!data)return ; + num_tx_queues =READ_ONCE (wx->num_tx_queues);rcu_read_lock (); -for (i =0 ; i < wx->num_tx_queues; i++) { +for (i =0 ; i < num_tx_queues; i++) {struct wx_ring *tx_ring =rcu_dereference (wx->tx_ring[i]);if (!tx_ring)
@@ -2915,6 +2919,7 @@ void wx_update_stats(struct wx *wx)u64 non_eop_descs =0 , alloc_rx_buff_failed =0 ;u64 hw_csum_rx_good =0 , hw_csum_rx_error =0 ;u64 restart_queue =0 , tx_busy =0 ; +int num_rx_queues, num_tx_queues;u32 i; if (test_bit(WX_STATE_DOWN, wx->state) ||
@@ -2923,9 +2928,11 @@ void wx_update_stats(struct wx *wx)spin_lock (&wx->hw_stats_lock); + num_rx_queues =READ_ONCE (wx->num_rx_queues); + num_tx_queues =READ_ONCE (wx->num_tx_queues);rcu_read_lock ();/* gather some stats to the wx struct that are per queue */ -for (i =0 ; i < wx->num_rx_queues; i++) { +for (i =0 ; i < num_rx_queues; i++) {struct wx_ring *rx_ring =rcu_dereference (wx->rx_ring[i]);if (!rx_ring)
@@ -2944,7 +2951,7 @@ void wx_update_stats(struct wx *wx)u64 rsc_count =0 ;u64 rsc_flush =0 ; -for (i =0 ; i < wx->num_rx_queues; i++) { +for (i =0 ; i < num_rx_queues; i++) {struct wx_ring *rx_ring =rcu_dereference (wx->rx_ring[i]);if (!rx_ring)
@@ -2957,7 +2964,7 @@ void wx_update_stats(struct wx *wx) wx->rsc_flush = rsc_flush; } -for (i =0 ; i < wx->num_tx_queues; i++) { +for (i =0 ; i < num_tx_queues; i++) {struct wx_ring *tx_ring =rcu_dereference (wx->tx_ring[i]);if (!tx_ring)
drivers/net/ethernet/wangxun/libwx/wx_lib.c +16 -13
@@ -1734,7 +1734,7 @@ netdev_tx_t wx_xmit_frame(struct sk_buff *skb,return NETDEV_TX_OK ; } - num_tx_queues = wx->num_tx_queues; + num_tx_queues =READ_ONCE (wx->num_tx_queues);if (unlikely (!num_tx_queues)) goto drop;
@@ -1897,8 +1897,8 @@ static bool wx_set_vmdq_queues(struct wx *wx) wx->num_rx_pools = vmdq_i; wx->num_rx_queues_per_pool = rss_i; - wx->num_rx_queues = vmdq_i * rss_i; - wx->num_tx_queues = vmdq_i * rss_i; +WRITE_ONCE (wx->num_rx_queues, vmdq_i * rss_i); +WRITE_ONCE (wx->num_tx_queues, vmdq_i * rss_i);return true; }
@@ -1943,15 +1943,15 @@ static void wx_set_rss_queues(struct wx *wx) } out: - wx->num_rx_queues = f->indices; - wx->num_tx_queues = f->indices; +WRITE_ONCE (wx->num_rx_queues, f->indices); +WRITE_ONCE (wx->num_tx_queues, f->indices); }static void wx_set_num_queues (struct wx *wx) {/* Start with base case */ - wx->num_rx_queues =1 ; - wx->num_tx_queues =1 ; +WRITE_ONCE (wx->num_rx_queues,1 ); +WRITE_ONCE (wx->num_tx_queues,1 ); wx->queues_per_pool =1 ;if (wx_set_vmdq_queues (wx))
@@ -2288,8 +2288,8 @@ static int wx_alloc_q_vectors(struct wx *wx)return 0 ; err_out: - wx->num_tx_queues =0 ; - wx->num_rx_queues =0 ; +WRITE_ONCE (wx->num_tx_queues,0 ); +WRITE_ONCE (wx->num_rx_queues,0 ); wx->num_q_vectors =0 ;while (v_idx--)
@@ -2310,8 +2310,8 @@ static void wx_free_q_vectors(struct wx *wx) {int v_idx = wx->num_q_vectors; - wx->num_tx_queues =0 ; - wx->num_rx_queues =0 ; +WRITE_ONCE (wx->num_tx_queues,0 ); +WRITE_ONCE (wx->num_rx_queues,0 ); wx->num_q_vectors =0 ;while (v_idx--)
@@ -3085,13 +3085,16 @@ void wx_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) {struct wx *wx =netdev_priv (netdev); +int num_rx_queues, num_tx_queues;struct wx_hw_stats *hwstats;int i;wx_update_stats (wx); + num_rx_queues =READ_ONCE (wx->num_rx_queues); + num_tx_queues =READ_ONCE (wx->num_tx_queues);rcu_read_lock (); -for (i =0 ; i < wx->num_rx_queues; i++) { +for (i =0 ; i < num_rx_queues; i++) {struct wx_ring *ring =rcu_dereference (wx->rx_ring[i]);u64 bytes, packets;unsigned int start;
@@ -3107,7 +3110,7 @@ void wx_get_stats64(struct net_device *netdev, } } -for (i =0 ; i < wx->num_tx_queues; i++) { +for (i =0 ; i < num_tx_queues; i++) {struct wx_ring *ring =rcu_dereference (wx->tx_ring[i]);u64 bytes, packets;unsigned int start;
drivers/net/ethernet/wangxun/libwx/wx_ptp.c +3 -2
@@ -296,8 +296,8 @@ static void wx_ptp_rx_hang(struct wx *wx) {struct wx_ring *rx_ring;unsigned long rx_event; +int num_rx_queues, n;u32 tsyncrxctl; -int n; tsyncrxctl =rd32 (wx,WX_PSR_1588_CTL );
@@ -311,8 +311,9 @@ static void wx_ptp_rx_hang(struct wx *wx)/* determine the most recent watchdog or rx_timestamp event */ rx_event = wx->last_rx_ptp_check; + num_rx_queues =READ_ONCE (wx->num_rx_queues);rcu_read_lock (); -for (n =0 ; n < wx->num_rx_queues; n++) { +for (n =0 ; n < num_rx_queues; n++) { rx_ring =rcu_dereference (wx->rx_ring[n]);if (!rx_ring)continue ;
drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c +2 -2
@@ -53,8 +53,8 @@ static const struct net_device_ops ngbevf_netdev_ops = {static void ngbevf_set_num_queues (struct wx *wx) {/* Start with base case */ - wx->num_rx_queues =1 ; - wx->num_tx_queues =1 ; +WRITE_ONCE (wx->num_rx_queues,1 ); +WRITE_ONCE (wx->num_tx_queues,1 ); }static int ngbevf_sw_init (struct wx *wx)
drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c +5 -5
@@ -53,8 +53,8 @@ static void txgbevf_set_num_queues(struct wx *wx)int ret =0 ;/* Start with base case */ - wx->num_rx_queues =1 ; - wx->num_tx_queues =1 ; +WRITE_ONCE (wx->num_rx_queues,1 ); +WRITE_ONCE (wx->num_tx_queues,1 );spin_lock_bh (&wx->mbx.mbx_lock);/* fetch queue configuration from the PF */
@@ -66,15 +66,15 @@ static void txgbevf_set_num_queues(struct wx *wx)/* we need as many queues as traffic classes */ if (num_tcs >1 ) { - wx->num_rx_queues = num_tcs; +WRITE_ONCE (wx->num_rx_queues, num_tcs); }else { rss =min_t (u16,num_online_cpus (),TXGBEVF_MAX_RSS_NUM ); queue =min_t (u16, wx->mac.max_rx_queues, wx->mac.max_tx_queues); rss =min_t (u16, queue, rss);if (wx->vfinfo->vf_api >= wx_mbox_api_13) { - wx->num_rx_queues = rss; - wx->num_tx_queues = rss; +WRITE_ONCE (wx->num_rx_queues, rss); +WRITE_ONCE (wx->num_tx_queues, rss); } } }
Signature · 1 line
2.30.1
Re: [PATCH net v8 2/2] net: wangxun: access queue counts consistently
Quoted 14 lines · Mengyuan Lou
Queue-vector teardown clears
wx->num_tx_queuesandwx->num_rx_queueswhile the netdev can remain registered. Lockless readers may use these counts as ring-array loop bounds while teardown is clearing the ring slots.wx_xmit_frame()also uses the Tx count to select a ring and must not divide by zero during teardown.Use
READ_ONCE()to take a single count snapshot in the lockless readers, and useWRITE_ONCE()for queue-count updates during scheme setup, teardown, and allocation-error handling, including the VF queue setup callbacks. Keep the existing NULL checks so a reader that observed an old non-zero count can safely skip ring slots that have since been cleared.wx_xmit_frame()retains its zero-count guard before queue-index modulo.
Quoted 2 lines
Fixes 3f703186113f ("net: libwx: Add irq flow functions")Signed-off-by Mengyuan Lou <[email protected]>
This patch feels more like hardening for net-next than a fix for net. But regardless the code changes look good to me.
...
[email protected]
maintainerRe: [PATCH net v8 2/2] net: wangxun: access queue counts consistently
Quoted 19 lines
2026年11月24日 19:24,Simon Horman <[email protected]> 写道:
Quoted 14 lines · Mengyuan Lou
Queue-vector teardown clears
wx->num_tx_queuesandwx->num_rx_queueswhile the netdev can remain registered. Lockless readers may use these counts as ring-array loop bounds while teardown is clearing the ring slots.wx_xmit_frame()also uses the Tx count to select a ring and must not divide by zero during teardown.Use
READ_ONCE()to take a single count snapshot in the lockless readers, and useWRITE_ONCE()for queue-count updates during scheme setup, teardown, and allocation-error handling, including the VF queue setup callbacks. Keep the existing NULL checks so a reader that observed an old non-zero count can safely skip ring slots that have since been cleared.wx_xmit_frame()retains its zero-count guard before queue-index modulo.
Quoted 5 lines
Quoted 2 lines
Fixes 3f703186113f ("net: libwx: Add irq flow functions")Signed-off-by Mengyuan Lou <[email protected]>This patch feels more like hardening for net-next than a fix for net. But regardless the code changes look good to me.
I think so.
Should I resend this patch?
Quoted 5 lines
Reviewed-by Simon Horman <[email protected]>...
Simon Horman
reviewerRe: [PATCH net v8 2/2] net: wangxun: access queue counts consistently
Quoted 19 lines · On Wed, Nov 25, 2026 at 09:36:46AM +0800, [email protected] wrote:
Quoted 19 lines
2026年11月24日 19:24,Simon Horman <[email protected]> 写道:
Quoted 14 lines · Mengyuan Lou
Queue-vector teardown clears
wx->num_tx_queuesandwx->num_rx_queueswhile the netdev can remain registered. Lockless readers may use these counts as ring-array loop bounds while teardown is clearing the ring slots.wx_xmit_frame()also uses the Tx count to select a ring and must not divide by zero during teardown.Use
READ_ONCE()to take a single count snapshot in the lockless readers, and useWRITE_ONCE()for queue-count updates during scheme setup, teardown, and allocation-error handling, including the VF queue setup callbacks. Keep the existing NULL checks so a reader that observed an old non-zero count can safely skip ring slots that have since been cleared.wx_xmit_frame()retains its zero-count guard before queue-index modulo.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Fixes 3f703186113f ("net: libwx: Add irq flow functions")Signed-off-by Mengyuan Lou <[email protected]>This patch feels more like hardening for net-next than a fix for net. But regardless the code changes look good to me.
I think so.
Should I resend this patch?
Thanks,
IMHO, it would be best to split the series in two: one patch for net and one for net-next. And resend both.
Paolo Abeni
maintainerRe: [PATCH net v8 2/2] net: wangxun: access queue counts consistently
Quoted 26 lines · Simon Horman
Quoted 25 lines · On Wed, Nov 25, 2026 at 09:36:46AM +0800, [email protected] wrote:
Quoted 24 lines
2026年11月24日 19:24,Simon Horman <[email protected]> 写道:
Quoted 14 lines · Mengyuan Lou
Queue-vector teardown clears
wx->num_tx_queuesandwx->num_rx_queueswhile the netdev can remain registered. Lockless readers may use these counts as ring-array loop bounds while teardown is clearing the ring slots.wx_xmit_frame()also uses the Tx count to select a ring and must not divide by zero during teardown.Use
READ_ONCE()to take a single count snapshot in the lockless readers, and useWRITE_ONCE()for queue-count updates during scheme setup, teardown, and allocation-error handling, including the VF queue setup callbacks. Keep the existing NULL checks so a reader that observed an old non-zero count can safely skip ring slots that have since been cleared.wx_xmit_frame()retains its zero-count guard before queue-index modulo.Quoted 2 lines
Fixes 3f703186113f ("net: libwx: Add irq flow functions")Signed-off-by Mengyuan Lou <[email protected]>This patch feels more like hardening for net-next than a fix for net. But regardless the code changes look good to me.
Quoted 7 lines
Quoted 2 lines
I think so.
Should I resend this patch?Thanks,
IMHO, it would be best to split the series in two: one patch for net and one for net-next. And resend both.
No need to resend. In fact both patches must be applied to net-next, as the first one has a functional dependency on a net-next pre-req.
/P
[email protected]
maintainerRe: [PATCH net v8 2/2] net: wangxun: access queue counts consistently
Quoted 31 lines
2026年11月25日 23:10,Paolo Abeni <[email protected]> 写道:
Quoted 26 lines · Simon Horman
Quoted 25 lines · On Wed, Nov 25, 2026 at 09:36:46AM +0800, [email protected] wrote:
Quoted 24 lines
2026年11月24日 19:24,Simon Horman <[email protected]> 写道:
Quoted 14 lines · Mengyuan Lou
Queue-vector teardown clears
wx->num_tx_queuesandwx->num_rx_queueswhile the netdev can remain registered. Lockless readers may use these counts as ring-array loop bounds while teardown is clearing the ring slots.wx_xmit_frame()also uses the Tx count to select a ring and must not divide by zero during teardown.Use
READ_ONCE()to take a single count snapshot in the lockless readers, and useWRITE_ONCE()for queue-count updates during scheme setup, teardown, and allocation-error handling, including the VF queue setup callbacks. Keep the existing NULL checks so a reader that observed an old non-zero count can safely skip ring slots that have since been cleared.wx_xmit_frame()retains its zero-count guard before queue-index modulo.Quoted 2 lines
Fixes 3f703186113f ("net: libwx: Add irq flow functions")Signed-off-by Mengyuan Lou <[email protected]>This patch feels more like hardening for net-next than a fix for net. But regardless the code changes look good to me.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I think so.
Should I resend this patch?Thanks,
IMHO, it would be best to split the series in two: one patch for net and one for net-next. And resend both.No need to resend. In fact both patches must be applied to net-next, as the first one has a functional dependency on a net-next pre-req.
Ok
Thanks.
Quoted 4 lines
/P
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
[email protected]
maintainerQuoted 4 lines
2026年11月18日 16:18,[email protected] 写道:
Quoted 8 lines
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
1) Discovery: The issue was found by code inspection of the wangxun ring/q_vector teardown paths, assisted by an LLM-based static analysis/review tool. The starting point was commit 3f703186113f ("net: libwx: Add irq flow functions"), where the TX/RX ring pointers and queue counts are accessed from lockless contexts (xmit, watchdog, PTP, ethtool) while teardown frees the q_vectors via kfree_rcu(). No external bug report was involved.
Quoted 4 lines
- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.
2) Triggered: Not so far. This is a race condition and the timing window is very narrow, so we were not able to reproduce the failure on the tested hardware. At this point it remains a theoretical concern identified by inspection rather than an observed crash or KCSAN report; the series is a preventive hardening fix.
Quoted 4 lines
- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.
3) Testing: The change was tested on WX1820 (TXGBE_DEV_ID_WX1820) and WX1860A4 (NGBE_DEV_ID_EM_WX1860A4) NICs. We confirmed that no other functionality was affected.
Quoted 12 lines
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Wed, 18 Nov 2026 16:13:27 +0800 you wrote:
This series protects Wangxun ring-array accesses during interrupt-scheme reconfiguration.
Patch 1 converts ring-pointer access to RCU and initializes
reg_idxbefore publishing each ring. Patch 2 pairs lockless queue-count reads and writes so readers remain safe while queue vectors are torn down or rebuilt.[...]
Here is the summary with links:
- [net,v8,1/2] net: wangxun: protect ring accesses with RCU
https://git.kernel.org/netdev/net-next/c/39c4174d0e9c - [net,v8,2/2] net: wangxun: access queue counts consistently https://git.kernel.org/netdev/net-next/c/174a5d00db9d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html