patch 'net/idpf: fix mbuf leak in split Tx' has been queued to stable release 22.11.2

Xueming Li xuemingl at nvidia.com
Mon Feb 27 08:00:40 CET 2023


Hi,

FYI, your patch has been queued to stable release 22.11.2

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

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

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 96ccb4c28795fde0b0d1d4db727bb04df9e09acd Mon Sep 17 00:00:00 2001
From: Jingjing Wu <jingjing.wu at intel.com>
Date: Fri, 6 Jan 2023 09:04:59 +0000
Subject: [PATCH] net/idpf: fix mbuf leak in split Tx
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 9e199987a3143a7d705f2c06213e0cf4b9380653 ]

When context descriptor is used during sending packets, mbuf
is not freed correctly, it will cause mempool be exhausted.
This patch refines the free function.

Fixes: 770f4dfe0f79 ("net/idpf: support basic Tx data path")

Signed-off-by: Jingjing Wu <jingjing.wu at intel.com>
Signed-off-by: Beilei Xing <beilei.xing at intel.com>
Acked-by: Qi Zhang <qi.z.zhang at intel.com>
---
 drivers/net/idpf/idpf_rxtx.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/net/idpf/idpf_rxtx.c b/drivers/net/idpf/idpf_rxtx.c
index b4a396c3f5..5aef8ba2b6 100644
--- a/drivers/net/idpf/idpf_rxtx.c
+++ b/drivers/net/idpf/idpf_rxtx.c
@@ -1508,6 +1508,7 @@ idpf_split_tx_free(struct idpf_tx_queue *cq)
 	struct idpf_tx_entry *txe;
 	struct idpf_tx_queue *txq;
 	uint16_t gen, qid, q_head;
+	uint16_t nb_desc_clean;
 	uint8_t ctype;

 	txd = &compl_ring[next];
@@ -1525,20 +1526,24 @@ idpf_split_tx_free(struct idpf_tx_queue *cq)

 	switch (ctype) {
 	case IDPF_TXD_COMPLT_RE:
-		if (q_head == 0)
-			txq->last_desc_cleaned = txq->nb_tx_desc - 1;
-		else
-			txq->last_desc_cleaned = q_head - 1;
-		if (unlikely((txq->last_desc_cleaned % 32) == 0)) {
+		/* clean to q_head which indicates be fetched txq desc id + 1.
+		 * TODO: need to refine and remove the if condition.
+		 */
+		if (unlikely(q_head % 32)) {
 			PMD_DRV_LOG(ERR, "unexpected desc (head = %u) completion.",
 						q_head);
 			return;
 		}
-
+		if (txq->last_desc_cleaned > q_head)
+			nb_desc_clean = (txq->nb_tx_desc - txq->last_desc_cleaned) +
+				q_head;
+		else
+			nb_desc_clean = q_head - txq->last_desc_cleaned;
+		txq->nb_free += nb_desc_clean;
+		txq->last_desc_cleaned = q_head;
 		break;
 	case IDPF_TXD_COMPLT_RS:
-		txq->nb_free++;
-		txq->nb_used--;
+		/* q_head indicates sw_id when ctype is 2 */
 		txe = &txq->sw_ring[q_head];
 		if (txe->mbuf != NULL) {
 			rte_pktmbuf_free_seg(txe->mbuf);
@@ -1693,12 +1698,16 @@ idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		/* fill the last descriptor with End of Packet (EOP) bit */
 		txd->qw1.cmd_dtype |= IDPF_TXD_FLEX_FLOW_CMD_EOP;

-		if (unlikely((tx_id % 32) == 0))
-			txd->qw1.cmd_dtype |= IDPF_TXD_FLEX_FLOW_CMD_RE;
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			txd->qw1.cmd_dtype |= IDPF_TXD_FLEX_FLOW_CMD_CS_EN;
 		txq->nb_free = (uint16_t)(txq->nb_free - nb_used);
 		txq->nb_used = (uint16_t)(txq->nb_used + nb_used);
+
+		if (txq->nb_used >= 32) {
+			txd->qw1.cmd_dtype |= IDPF_TXD_FLEX_FLOW_CMD_RE;
+			/* Update txq RE bit counters */
+			txq->nb_used = 0;
+		}
 	}

 	/* update the tail pointer if any packets were processed */
--
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-02-27 14:08:45.132215400 +0800
+++ 0133-net-idpf-fix-mbuf-leak-in-split-Tx.patch	2023-02-27 14:08:40.919237000 +0800
@@ -1 +1 @@
-From 9e199987a3143a7d705f2c06213e0cf4b9380653 Mon Sep 17 00:00:00 2001
+From 96ccb4c28795fde0b0d1d4db727bb04df9e09acd Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 9e199987a3143a7d705f2c06213e0cf4b9380653 ]
@@ -11 +13,0 @@
-Cc: stable at dpdk.org


More information about the stable mailing list