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 <[email protected]>
---
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