Skip to content

Commit 08b42b6

Browse files
Maxim Mikityanskiygregkh
authored andcommitted
net/mlx5e: Replace synchronize_rcu with synchronize_net
[ Upstream commit 4d6e6b0 ] The commit cited below switched from using napi_synchronize to synchronize_rcu to have a guarantee that it will finish in finite time. However, on average, synchronize_rcu takes more time than napi_synchronize. Given that it's called multiple times per channel on deactivation, it accumulates to a significant amount, which causes timeouts in some applications (for example, when using bonding with NetworkManager). This commit replaces synchronize_rcu with synchronize_net, which is faster when called under rtnl_lock, allowing to speed up the described flow. Fixes: 9c25a22 ("net/mlx5e: Use synchronize_rcu to sync with NAPI") Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 27c79b3 commit 08b42b6

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static inline void mlx5e_xdp_tx_disable(struct mlx5e_priv *priv)
8383

8484
clear_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
8585
/* Let other device's napi(s) and XSK wakeups see our new state. */
86-
synchronize_rcu();
86+
synchronize_net();
8787
}
8888

8989
static inline bool mlx5e_xdp_tx_is_enabled(struct mlx5e_priv *priv)

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
106106
void mlx5e_close_xsk(struct mlx5e_channel *c)
107107
{
108108
clear_bit(MLX5E_CHANNEL_STATE_XSK, c->state);
109-
synchronize_rcu(); /* Sync with the XSK wakeup and with NAPI. */
109+
synchronize_net(); /* Sync with the XSK wakeup and with NAPI. */
110110

111111
mlx5e_close_rq(&c->xskrq);
112112
mlx5e_close_cq(&c->xskrq.cq);

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ void mlx5e_ktls_del_rx(struct net_device *netdev, struct tls_context *tls_ctx)
663663
priv_rx = mlx5e_get_ktls_rx_priv_ctx(tls_ctx);
664664
set_bit(MLX5E_PRIV_RX_FLAG_DELETING, priv_rx->flags);
665665
mlx5e_set_ktls_rx_priv_ctx(tls_ctx, NULL);
666-
synchronize_rcu(); /* Sync with NAPI */
666+
synchronize_net(); /* Sync with NAPI */
667667
if (!cancel_work_sync(&priv_rx->rule.work))
668668
/* completion is needed, as the priv_rx in the add flow
669669
* is maintained on the wqe info (wi), not on the socket.

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ void mlx5e_activate_rq(struct mlx5e_rq *rq)
919919
void mlx5e_deactivate_rq(struct mlx5e_rq *rq)
920920
{
921921
clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
922-
synchronize_rcu(); /* Sync with NAPI to prevent mlx5e_post_rx_wqes. */
922+
synchronize_net(); /* Sync with NAPI to prevent mlx5e_post_rx_wqes. */
923923
}
924924

925925
void mlx5e_close_rq(struct mlx5e_rq *rq)
@@ -1380,7 +1380,7 @@ static void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq)
13801380
struct mlx5_wq_cyc *wq = &sq->wq;
13811381

13821382
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
1383-
synchronize_rcu(); /* Sync with NAPI to prevent netif_tx_wake_queue. */
1383+
synchronize_net(); /* Sync with NAPI to prevent netif_tx_wake_queue. */
13841384

13851385
mlx5e_tx_disable_queue(sq->txq);
13861386

@@ -1456,7 +1456,7 @@ void mlx5e_activate_icosq(struct mlx5e_icosq *icosq)
14561456
void mlx5e_deactivate_icosq(struct mlx5e_icosq *icosq)
14571457
{
14581458
clear_bit(MLX5E_SQ_STATE_ENABLED, &icosq->state);
1459-
synchronize_rcu(); /* Sync with NAPI. */
1459+
synchronize_net(); /* Sync with NAPI. */
14601460
}
14611461

14621462
void mlx5e_close_icosq(struct mlx5e_icosq *sq)
@@ -1535,7 +1535,7 @@ void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq)
15351535
struct mlx5e_channel *c = sq->channel;
15361536

15371537
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
1538-
synchronize_rcu(); /* Sync with NAPI. */
1538+
synchronize_net(); /* Sync with NAPI. */
15391539

15401540
mlx5e_destroy_sq(c->mdev, sq->sqn);
15411541
mlx5e_free_xdpsq_descs(sq);

0 commit comments

Comments
 (0)