[dpdk-dev] [PATCH] net/mlx5: fix counter query fail during port closing

Suanming Mou suanmingm at mellanox.com
Fri May 15 10:56:43 CEST 2020


Currently, the DevX counter query works asynchronously with Devx
interrupt handler return the query result. When port closes, the
interrupt handler will be uninstalled and the Devx comp obj will
also be destroyed. Meanwhile the query is still not cancelled.
In this case, counter query may use the invalid Devx comp which
has been destroyed, and query failure with invalid FD will be
reported.

Move the query alarm cancel before Devx interrupt uninstall to
avoid query failure with invalid FD issue.

Fixes: f15db67df09c ("net/mlx5: accelerate DV flow counter query")
Cc: stable at dpdk.org

Signed-off-by: Suanming Mou <suanmingm at mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo at mellanox.com>
---
Please apply the patch after the patch below:
https://patches.dpdk.org/patch/70310/
---
 drivers/net/mlx5/mlx5.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index be16841..579da76 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -506,15 +506,7 @@ struct mlx5_flow_id_pool *
 	struct mlx5_counter_stats_mem_mng *mng;
 	int i;
 	int j;
-	int retries = 1024;
 
-	rte_errno = 0;
-	while (--retries) {
-		rte_eal_alarm_cancel(mlx5_flow_query_alarm, sh);
-		if (rte_errno != EINPROGRESS)
-			break;
-		rte_pause();
-	}
 	for (i = 0; i < MLX5_CCONT_TYPE_MAX; ++i) {
 		struct mlx5_flow_counter_pool *pool;
 		uint32_t batch = !!(i > 1);
@@ -1427,6 +1419,23 @@ struct mlx5_flow_id_pool *
 		dev->data->port_id,
 		((priv->sh && priv->sh->ctx) ?
 		priv->sh->ctx->device->name : ""));
+	/*
+	 * The devx->comp is going to be destroyed in
+	 * mlx5_dev_interrupt_handler_devx_uninstall(), stop the asynchronous
+	 * counter query in advanced in case the devx->comp destroyed during
+	 * query causes invalid fd used.
+	 */
+	if (priv->sh) {
+		int retries = 1024;
+
+		rte_errno = 0;
+		while (--retries) {
+			rte_eal_alarm_cancel(mlx5_flow_query_alarm, priv->sh);
+			if (rte_errno != EINPROGRESS)
+				break;
+			rte_pause();
+		}
+	}
 	/* In case mlx5_dev_stop() has not been called. */
 	mlx5_dev_interrupt_handler_uninstall(dev);
 	mlx5_dev_interrupt_handler_devx_uninstall(dev);
-- 
1.8.3.1



More information about the dev mailing list