* [PATCH iwl-next 0/2] i40e, ice: one RCU grace period per XDP ring teardown
@ 2026-11-20 15:05 Shitalkumar Gandhi
2026-11-20 15:05 ` [PATCH iwl-next 1/2] i40e: wait for one RCU grace period in i40e_down(), not one per queue Shitalkumar Gandhi
2026-11-20 15:05 ` [PATCH iwl-next 2/2] ice: wait for one RCU grace period when destroying XDP rings Shitalkumar Gandhi
0 siblings, 2 replies; 5+ messages in thread
From: Shitalkumar Gandhi @ 2026-11-20 15:05 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, intel-wired-lan
Cc: netdev, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev, bpf,
Shitalkumar Gandhi
Both i40e and ice wait for an RCU grace period once per XDP Tx ring
when tearing the rings down, so the time spent scales with the number
of queues (i40e) or CPUs (ice). The wait only has to cover in-progress
ndo_xdp_xmit and ndo_xsk_wakeup calls, and one grace period taken
before the loop does that for all rings.
Compile-tested with W=1 (allmodconfig, x86_64); not run on hardware.
Shitalkumar Gandhi (2):
i40e: wait for one RCU grace period in i40e_down(), not one per queue
ice: wait for one RCU grace period when destroying XDP rings
drivers/net/ethernet/intel/i40e/i40e_main.c | 15 +++++++++------
drivers/net/ethernet/intel/ice/ice_main.c | 10 +++++++---
2 files changed, 16 insertions(+), 9 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH iwl-next 1/2] i40e: wait for one RCU grace period in i40e_down(), not one per queue
2026-11-20 15:05 [PATCH iwl-next 0/2] i40e, ice: one RCU grace period per XDP ring teardown Shitalkumar Gandhi
@ 2026-11-20 15:05 ` Shitalkumar Gandhi
2026-11-20 15:17 ` sashiko-bot
2026-11-20 15:05 ` [PATCH iwl-next 2/2] ice: wait for one RCU grace period when destroying XDP rings Shitalkumar Gandhi
1 sibling, 1 reply; 5+ messages in thread
From: Shitalkumar Gandhi @ 2026-11-20 15:05 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, intel-wired-lan
Cc: netdev, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev, bpf,
Shitalkumar Gandhi
i40e_down() calls synchronize_rcu() inside the per-queue loop whenever
XDP is enabled, so bringing a VSI down waits for num_queue_pairs
back-to-back grace periods. This is paid on every ifdown, reset, MTU
change and XDP attach/detach.
The wait is there so that in-progress ndo_xdp_xmit and ndo_xsk_wakeup
calls have finished before the XDP rings are cleaned. Both bail out
when __I40E_VSI_DOWN is set. When the caller has set it, as
i40e_vsi_close() and the reset path do, a single grace period after
that covers every ring. Callers that do not set it,
i40e_vsi_reinit_locked() and i40e_set_ringparam(), are not protected
against new calls by the per-queue wait either: a call can start right
after any of those grace periods.
Wait once, before the loop. While at it, use synchronize_net(), which
takes the expedited path when rtnl is held, as commit 405d9999aa0b
("ice: replace synchronize_rcu with synchronize_net") did for the same
pattern in ice.
Signed-off-by: Shitalkumar Gandhi <shital.gandhi45@gmail.com>
---
drivers/net/ethernet/intel/i40e/i40e_main.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index abbc71e81..99f59079d 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -7611,15 +7611,18 @@ void i40e_down(struct i40e_vsi *vsi)
i40e_force_link_state(vsi->back, false);
i40e_napi_disable_all(vsi);
+ /* Make sure that in-progress ndo_xdp_xmit and ndo_xsk_wakeup calls
+ * are completed before the XDP rings are cleaned. They bail out on
+ * __I40E_VSI_DOWN, which the caller has set, so a single grace
+ * period covers all rings.
+ */
+ if (i40e_enabled_xdp_vsi(vsi))
+ synchronize_net();
+
for (i = 0; i < vsi->num_queue_pairs; i++) {
i40e_clean_tx_ring(vsi->tx_rings[i]);
- if (i40e_enabled_xdp_vsi(vsi)) {
- /* Make sure that in-progress ndo_xdp_xmit and
- * ndo_xsk_wakeup calls are completed.
- */
- synchronize_rcu();
+ if (i40e_enabled_xdp_vsi(vsi))
i40e_clean_tx_ring(vsi->xdp_rings[i]);
- }
i40e_clean_rx_ring(vsi->rx_rings[i]);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH iwl-next 2/2] ice: wait for one RCU grace period when destroying XDP rings
2026-11-20 15:05 [PATCH iwl-next 0/2] i40e, ice: one RCU grace period per XDP ring teardown Shitalkumar Gandhi
2026-11-20 15:05 ` [PATCH iwl-next 1/2] i40e: wait for one RCU grace period in i40e_down(), not one per queue Shitalkumar Gandhi
@ 2026-11-20 15:05 ` Shitalkumar Gandhi
2026-11-20 15:13 ` sashiko-bot
1 sibling, 1 reply; 5+ messages in thread
From: Shitalkumar Gandhi @ 2026-11-20 15:05 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, intel-wired-lan
Cc: netdev, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev, bpf,
Shitalkumar Gandhi
ice_destroy_xdp_rings() calls synchronize_rcu() for every XDP Tx ring
before freeing it. num_xdp_txq is sized to the number of CPUs, so on a
large machine detaching an XDP program or rebuilding the VSI waits for
well over a hundred back-to-back grace periods.
The wait makes sure in-progress ndo_xdp_xmit and ndo_xsk_wakeup calls
have left the ring. Both return early when ICE_VSI_DOWN is set.
ice_xdp_setup_prog() takes the VSI down before destroying the rings,
and ice_vsi_decfg() runs on release or rebuild after the VSI has been
closed, so a single grace period before the loop covers all rings. Do
that, and use synchronize_net() as ice_qp_dis() already does since
commit 405d9999aa0b ("ice: replace synchronize_rcu with
synchronize_net").
Signed-off-by: Shitalkumar Gandhi <shital.gandhi45@gmail.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 47c6798c9..ed5103e8c 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -2802,12 +2802,16 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi, enum ice_xdp_cfg cfg_type)
}
mutex_unlock(&pf->avail_q_mutex);
+ /* Let in-progress ndo_xdp_xmit and ndo_xsk_wakeup calls finish before
+ * the rings they may be using are freed. The VSI is down at this
+ * point, so one grace period is enough for all rings.
+ */
+ synchronize_net();
+
ice_for_each_xdp_txq(vsi, i)
if (vsi->xdp_rings[i]) {
- if (vsi->xdp_rings[i]->desc) {
- synchronize_rcu();
+ if (vsi->xdp_rings[i]->desc)
ice_free_tx_ring(vsi->xdp_rings[i]);
- }
kfree_rcu(vsi->xdp_rings[i]->ring_stats, rcu);
vsi->xdp_rings[i]->ring_stats = NULL;
kfree_rcu(vsi->xdp_rings[i], rcu);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH iwl-next 2/2] ice: wait for one RCU grace period when destroying XDP rings
2026-11-20 15:05 ` [PATCH iwl-next 2/2] ice: wait for one RCU grace period when destroying XDP rings Shitalkumar Gandhi
@ 2026-11-20 15:13 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-20 15:13 UTC (permalink / raw)
To: Shitalkumar Gandhi, intel-wired-lan; +Cc: bpf
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] ice: use-after-free in ice_vsi_clear_rings() [1]
--
commit 43d9078a23fe9ac7d73bcbe7267574a26a1906b4
Author: Shitalkumar Gandhi <shital.gandhi45@gmail.com>
ice: wait for one RCU grace period when destroying XDP rings
This commit replaces the per-ring synchronize_rcu() in
ice_destroy_xdp_rings() with a single synchronize_net() call before the
ring teardown loop.
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 0d823e7f4cdcd..254668d4e3963 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -2891,12 +2891,16 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi, enum ice_xdp_cfg cfg_type)
> }
> mutex_unlock(&pf->avail_q_mutex);
>
> + /* Let in-progress ndo_xdp_xmit and ndo_xsk_wakeup calls finish before
> + * the rings they may be using are freed. The VSI is down at this
> + * point, so one grace period is enough for all rings.
> + */
> + synchronize_net();
> +
> ice_for_each_xdp_txq(vsi, i)
> if (vsi->xdp_rings[i]) {
> - if (vsi->xdp_rings[i]->desc) {
> - synchronize_rcu();
> + if (vsi->xdp_rings[i]->desc)
> ice_free_tx_ring(vsi->xdp_rings[i]);
> - }
> kfree_rcu(vsi->xdp_rings[i]->ring_stats, rcu);
> vsi->xdp_rings[i]->ring_stats = NULL;
> kfree_rcu(vsi->xdp_rings[i], rcu);
[Severity: Critical]
This problem wasn't introduced by this patch, but can calling kfree_rcu()
on vsi->xdp_rings[i]->ring_stats and vsi->xdp_rings[i] before clearing
those pointers cause a use-after-free [1]?
An RCU reader entering between kfree_rcu() and the NULL assignment can
still observe the pointer after the grace period for reclaiming it has
already started, so the object can be freed while the reader is using it
(the same ordering also exists in ice_vsi_clear_rings() for vsi->tx_rings
and vsi->rx_rings).
[1] https://sashiko.dev/#/bug/linux-8bb69a7d-5d05-41df-ae26-5fe9622f437d
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120150527.14649-1-shital.gandhi45@gmail.com?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH iwl-next 1/2] i40e: wait for one RCU grace period in i40e_down(), not one per queue
2026-11-20 15:05 ` [PATCH iwl-next 1/2] i40e: wait for one RCU grace period in i40e_down(), not one per queue Shitalkumar Gandhi
@ 2026-11-20 15:17 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-20 15:17 UTC (permalink / raw)
To: Shitalkumar Gandhi, intel-wired-lan; +Cc: bpf
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] i40e: unpaired napi_disable() in i40e_vsi_open() [1]
--
commit e3081b5b3e5283a7fdd835e0d6be52ee866385e0
Author: Shitalkumar Gandhi <shital.gandhi45@gmail.com>
i40e: wait for one RCU grace period in i40e_down(), not one per queue
This commit moves the RCU wait in i40e_down() out of the per-queue loop
and replaces synchronize_rcu() with a single synchronize_net() call when
XDP is enabled.
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index 98d2fcdcee68f..e0c76ba566ea5 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -7609,15 +7609,18 @@ void i40e_down(struct i40e_vsi *vsi)
> i40e_force_link_state(vsi->back, false);
> i40e_napi_disable_all(vsi);
[Severity: High]
This problem wasn't introduced by this patch, but can
i40e_napi_disable_all() hang here when i40e_vsi_open() fails in
i40e_up_complete() [1]?
If i40e_vsi_start_rings() fails in i40e_up_complete(), it returns before
i40e_napi_enable_all() runs:
drivers/net/ethernet/intel/i40e/i40e_main.c:i40e_up_complete() {
...
err = i40e_vsi_start_rings(vsi);
if (err)
return err;
clear_bit(__I40E_VSI_DOWN, vsi->state);
i40e_napi_enable_all(vsi);
...
}
The err_up_complete error path in i40e_vsi_open() then calls i40e_down() ->
i40e_napi_disable_all() -> napi_disable() on NAPI instances where
NAPIF_STATE_SCHED and NAPIF_STATE_NPSVC were never cleared by
napi_enable(), sleeping forever while holding rtnl_lock().
[1] https://sashiko.dev/#/bug/linux-f4bedeae-9add-4cf7-9ab5-6f1f169023a5
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120150527.14649-1-shital.gandhi45@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-20 15:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 15:05 [PATCH iwl-next 0/2] i40e, ice: one RCU grace period per XDP ring teardown Shitalkumar Gandhi
2026-11-20 15:05 ` [PATCH iwl-next 1/2] i40e: wait for one RCU grace period in i40e_down(), not one per queue Shitalkumar Gandhi
2026-11-20 15:17 ` sashiko-bot
2026-11-20 15:05 ` [PATCH iwl-next 2/2] ice: wait for one RCU grace period when destroying XDP rings Shitalkumar Gandhi
2026-11-20 15:13 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox