patch 'net/mlx5: fix mutex unlock in Tx packet pacing cleanup' has been queued to stable release 20.11.4

Xueming Li xuemingl at nvidia.com
Sun Nov 28 15:53:54 CET 2021


Hi,

FYI, your patch has been queued to stable release 20.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/30/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/2b0a3cc701098a342c1bcd0af7abc79aab4c62b9

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 2b0a3cc701098a342c1bcd0af7abc79aab4c62b9 Mon Sep 17 00:00:00 2001
From: Chengfeng Ye <cyeaa at connect.ust.hk>
Date: Tue, 16 Nov 2021 06:49:23 -0800
Subject: [PATCH] net/mlx5: fix mutex unlock in Tx packet pacing cleanup
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 1e580ed4b0ff6afb23043f664ce30fe449e40d71 ]

The lock sh->txpp.mutex was not correctly released on one path
of cleanup function return, potentially causing the deadlock.

Fixes: d133f4cdb706 ("net/mlx5: create clock queue for packet pacing")

Signed-off-by: Chengfeng Ye <cyeaa at connect.ust.hk>
Acked-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
---
 drivers/net/mlx5/mlx5_txpp.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index cf11048160..1f4c1081f5 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -1049,7 +1049,6 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_dev_ctx_shared *sh = priv->sh;
 	int err = 0;
-	int ret;
 
 	if (!priv->config.tx_pp) {
 		/* Packet pacing is not requested for the device. */
@@ -1062,14 +1061,14 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
 		return 0;
 	}
 	if (priv->config.tx_pp > 0) {
-		ret = rte_mbuf_dynflag_lookup
-				(RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL);
-		if (ret < 0)
+		err = rte_mbuf_dynflag_lookup
+			(RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL);
+		/* No flag registered means no service needed. */
+		if (err < 0)
 			return 0;
+		err = 0;
 	}
-	ret = pthread_mutex_lock(&sh->txpp.mutex);
-	MLX5_ASSERT(!ret);
-	RTE_SET_USED(ret);
+	claim_zero(pthread_mutex_lock(&sh->txpp.mutex));
 	if (sh->txpp.refcnt) {
 		priv->txpp_en = 1;
 		++sh->txpp.refcnt;
@@ -1083,9 +1082,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
 			rte_errno = -err;
 		}
 	}
-	ret = pthread_mutex_unlock(&sh->txpp.mutex);
-	MLX5_ASSERT(!ret);
-	RTE_SET_USED(ret);
+	claim_zero(pthread_mutex_unlock(&sh->txpp.mutex));
 	return err;
 }
 
@@ -1103,24 +1100,21 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_dev_ctx_shared *sh = priv->sh;
-	int ret;
 
 	if (!priv->txpp_en) {
 		/* Packet pacing is already disabled for the device. */
 		return;
 	}
 	priv->txpp_en = 0;
-	ret = pthread_mutex_lock(&sh->txpp.mutex);
-	MLX5_ASSERT(!ret);
-	RTE_SET_USED(ret);
+	claim_zero(pthread_mutex_lock(&sh->txpp.mutex));
 	MLX5_ASSERT(sh->txpp.refcnt);
-	if (!sh->txpp.refcnt || --sh->txpp.refcnt)
+	if (!sh->txpp.refcnt || --sh->txpp.refcnt) {
+		claim_zero(pthread_mutex_unlock(&sh->txpp.mutex));
 		return;
+	}
 	/* No references any more, do actual destroy. */
 	mlx5_txpp_destroy(sh);
-	ret = pthread_mutex_unlock(&sh->txpp.mutex);
-	MLX5_ASSERT(!ret);
-	RTE_SET_USED(ret);
+	claim_zero(pthread_mutex_unlock(&sh->txpp.mutex));
 }
 
 /*
-- 
2.34.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-11-28 22:41:05.911375618 +0800
+++ 0050-net-mlx5-fix-mutex-unlock-in-Tx-packet-pacing-cleanu.patch	2021-11-28 22:41:03.370206742 +0800
@@ -1 +1 @@
-From 1e580ed4b0ff6afb23043f664ce30fe449e40d71 Mon Sep 17 00:00:00 2001
+From 2b0a3cc701098a342c1bcd0af7abc79aab4c62b9 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 1e580ed4b0ff6afb23043f664ce30fe449e40d71 ]
@@ -10 +12,0 @@
-Cc: stable at dpdk.org
@@ -19 +21 @@
-index 927c327284..af77e91e4c 100644
+index cf11048160..1f4c1081f5 100644
@@ -22 +24 @@
-@@ -890,7 +890,6 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
+@@ -1049,7 +1049,6 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
@@ -30 +32 @@
-@@ -903,14 +902,14 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
+@@ -1062,14 +1061,14 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
@@ -51 +53 @@
-@@ -924,9 +923,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
+@@ -1083,9 +1082,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev)
@@ -62 +64 @@
-@@ -944,24 +941,21 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
+@@ -1103,24 +1100,21 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)


More information about the stable mailing list