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 --- 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