patch 'net/mlx5: fix shared Rx queue control release' has been queued to stable release 23.11.3

Xueming Li xuemingl at nvidia.com
Sat Dec 7 09:00:42 CET 2024


Hi,

FYI, your patch has been queued to stable release 23.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/10/24. 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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=b4da83237f4577c1b8e97f97e5f9a9b017726270

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From b4da83237f4577c1b8e97f97e5f9a9b017726270 Mon Sep 17 00:00:00 2001
From: Bing Zhao <bingz at nvidia.com>
Date: Mon, 25 Nov 2024 19:23:18 +0200
Subject: [PATCH] net/mlx5: fix shared Rx queue control release
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit f8f294c66b5ff6ee89590cce56a3d733513ff9a0 ]

Correct the reference counting and condition checking for shared Rx
queue control structures. This fix ensures proper memory management
during port stop and device close stages.

The changes move the control structure reference count decrease
outside the owners list empty condition, and adjust the reference
count check to subtract first, then evaluate.

This prevents potential crashes during port restart by
ensuring shared Rx queues' control structures are properly freed.

Fixes: 3c9a82fa6edc ("net/mlx5: fix Rx queue control management")

Signed-off-by: Bing Zhao <bingz at nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski at nvidia.com>
---
 drivers/net/mlx5/mlx5_rx.h  |  2 +-
 drivers/net/mlx5/mlx5_rxq.c | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h
index f78fae26d3..db912adf2a 100644
--- a/drivers/net/mlx5/mlx5_rx.h
+++ b/drivers/net/mlx5/mlx5_rx.h
@@ -157,7 +157,7 @@ struct mlx5_rxq_ctrl {
 	bool is_hairpin; /* Whether RxQ type is Hairpin. */
 	unsigned int socket; /* CPU socket ID for allocations. */
 	LIST_ENTRY(mlx5_rxq_ctrl) share_entry; /* Entry in shared RXQ list. */
-	RTE_ATOMIC(uint32_t) ctrl_ref; /* Reference counter. */
+	RTE_ATOMIC(int32_t) ctrl_ref; /* Reference counter. */
 	uint32_t share_group; /* Group ID of shared RXQ. */
 	uint16_t share_qid; /* Shared RxQ ID in group. */
 	unsigned int started:1; /* Whether (shared) RXQ has been started. */
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 6d28bcb57c..dccfc4eb36 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2269,6 +2269,7 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx)
 	struct mlx5_rxq_priv *rxq;
 	struct mlx5_rxq_ctrl *rxq_ctrl;
 	uint32_t refcnt;
+	int32_t ctrl_ref;

 	if (priv->rxq_privs == NULL)
 		return 0;
@@ -2294,15 +2295,14 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx)
 		}
 	} else { /* Refcnt zero, closing device. */
 		LIST_REMOVE(rxq, owner_entry);
-		if (LIST_EMPTY(&rxq_ctrl->owners)) {
+		ctrl_ref = rte_atomic_fetch_sub_explicit(&rxq_ctrl->ctrl_ref, 1,
+							 rte_memory_order_relaxed) - 1;
+		if (ctrl_ref == 1 && LIST_EMPTY(&rxq_ctrl->owners)) {
 			if (!rxq_ctrl->is_hairpin)
 				mlx5_mr_btree_free
 					(&rxq_ctrl->rxq.mr_ctrl.cache_bh);
-			if (rte_atomic_fetch_sub_explicit(&rxq_ctrl->ctrl_ref, 1,
-			    rte_memory_order_relaxed) == 1) {
-				LIST_REMOVE(rxq_ctrl, share_entry);
-				mlx5_free(rxq_ctrl);
-			}
+			LIST_REMOVE(rxq_ctrl, share_entry);
+			mlx5_free(rxq_ctrl);
 		}
 		dev->data->rx_queues[idx] = NULL;
 		mlx5_free(rxq);
--
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-12-06 23:26:46.895414505 +0800
+++ 0084-net-mlx5-fix-shared-Rx-queue-control-release.patch	2024-12-06 23:26:44.093044826 +0800
@@ -1 +1 @@
-From f8f294c66b5ff6ee89590cce56a3d733513ff9a0 Mon Sep 17 00:00:00 2001
+From b4da83237f4577c1b8e97f97e5f9a9b017726270 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit f8f294c66b5ff6ee89590cce56a3d733513ff9a0 ]
@@ -18 +20,0 @@
-Cc: stable at dpdk.org
@@ -28 +30 @@
-index da7c448948..1a6f174c40 100644
+index f78fae26d3..db912adf2a 100644
@@ -41 +43 @@
-index 0737f60272..126b1970e6 100644
+index 6d28bcb57c..dccfc4eb36 100644
@@ -44 +46 @@
-@@ -2268,6 +2268,7 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx)
+@@ -2269,6 +2269,7 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx)
@@ -52 +54 @@
-@@ -2293,15 +2294,14 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx)
+@@ -2294,15 +2295,14 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx)


More information about the stable mailing list