patch 'net/hns3: fix mbuf leakage when RxQ started after reset' has been queued to stable release 20.11.9

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Jun 15 03:32:28 CEST 2023


Hi,

FYI, your patch has been queued to stable release 20.11.9

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/17/23. 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/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/755159ae805c7d106b72f8a2157e338581454377

Thanks.

Luca Boccassi

---
>From 755159ae805c7d106b72f8a2157e338581454377 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen at huawei.com>
Date: Fri, 2 Jun 2023 19:42:00 +0800
Subject: [PATCH] net/hns3: fix mbuf leakage when RxQ started after reset

[ upstream commit f81a18f491522c56ca7ee6ea78be10c784f2ae32 ]

In the reset restore-conf phase, the reset process will allocate for
the Rx ring mbufs unconditionlly.

And the rte_eth_dev_rx_queue_start() will also allocate for the Rx ring
mbufs unconditionlly.

So if the rte_eth_dev_rx_queue_start() is invoked after restore-conf
phase, then the mbufs allocated in restore-conf phase will leak.

So fix it by conditional release Rx ring mbufs in
rte_eth_dev_rx_queue_start(): if the Rx ring mbufs were allocated then
release them first.

This patch also set all sw-ring[]'s mbuf is NULL when release Rx ring
mbufs so that we can determine whether the Rx ring mbufs were allocated
based only on the first sw-ring[0]'s mbuf.

Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop")

Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3 at huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 86fac45d5f..bf07a5071a 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -54,6 +54,8 @@ hns3_rx_queue_release_mbufs(struct hns3_rx_queue *rxq)
 				rxq->sw_ring[i].mbuf = NULL;
 			}
 		}
+		for (i = 0; i < rxq->rx_rearm_nb; i++)
+			rxq->sw_ring[rxq->rx_rearm_start + i].mbuf = NULL;
 	}
 
 	for (i = 0; i < rxq->bulk_mbuf_num; i++)
@@ -4012,6 +4014,9 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return ret;
 	}
 
+	if (rxq->sw_ring[0].mbuf != NULL)
+		hns3_rx_queue_release_mbufs(rxq);
+
 	ret = hns3_init_rxq(hns, rx_queue_id);
 	if (ret) {
 		hns3_err(hw, "fail to init Rx queue %u, ret = %d.",
-- 
2.39.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-06-15 01:56:36.451052121 +0100
+++ 0033-net-hns3-fix-mbuf-leakage-when-RxQ-started-after-res.patch	2023-06-15 01:56:34.611542265 +0100
@@ -1 +1 @@
-From f81a18f491522c56ca7ee6ea78be10c784f2ae32 Mon Sep 17 00:00:00 2001
+From 755159ae805c7d106b72f8a2157e338581454377 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit f81a18f491522c56ca7ee6ea78be10c784f2ae32 ]
+
@@ -24 +25,0 @@
-Cc: stable at dpdk.org
@@ -33 +34 @@
-index 2bfc5507e3..2493748683 100644
+index 86fac45d5f..bf07a5071a 100644
@@ -36 +37 @@
-@@ -50,6 +50,8 @@ hns3_rx_queue_release_mbufs(struct hns3_rx_queue *rxq)
+@@ -54,6 +54,8 @@ hns3_rx_queue_release_mbufs(struct hns3_rx_queue *rxq)
@@ -45 +46 @@
-@@ -4538,6 +4540,9 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+@@ -4012,6 +4014,9 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)


More information about the stable mailing list