Skip to contentSkip to conversation

net/iavf: fix core dump when exiting testpmd

PATCH Superseded Kaiwen Deng 3 participants 12 messages Oct 26, 2023 – Nov 9, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/iavf: fix core dump when exiting testpmd

release null mbuf results coredump.
This commit adding mbuf check before releasing.

Fixes 12016895fcf3 ("net/iavf: fix buffer leak on Tx queue stop")
---
 drivers/net/iavf/iavf_rxtx_vec_common.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_rxtx_vec_common.h +5 -2
index e18cdc3f11..f50a500536 100644
@@ -187,8 +187,11 @@ _iavf_tx_queue_release_mbufs_vec(struct iavf_tx_queue *txq)
 
 	i = txq->next_dd - txq->rs_thresh + 1;
 	while (i != txq->tx_tail) {
-		rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
-		txq->sw_ring[i].mbuf = NULL;
+		if (txq->sw_ring[i].mbuf) {
+			rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
+			txq->sw_ring[i].mbuf = NULL;
+		}
+
 		if (++i == txq->nb_tx_desc)
 			i = 0;
 	}
Signature · 1 line
2.34.1
#1 lore raw
Quoted 29 lines

-----Original Message-----
From: Kaiwen Deng <[email protected]>
Sent: Thursday, October 26, 2023 4:55 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Lu, Wenzhuo <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH] net/iavf: fix core dump when exiting testpmd

release null mbuf results coredump.
This commit adding mbuf check before releasing.

Fixes 12016895fcf3 ("net/iavf: fix buffer leak on Tx queue stop")
---
 drivers/net/iavf/iavf_rxtx_vec_common.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_rxtx_vec_common.h +0 -0
index e18cdc3f11..f50a500536 100644

drivers/net/iavf/iavf_rxtx_vec_common.h _iavf_tx_queue_release_mbufs_vec(struct · line 194

Quoted 10 lines
drivers/net/iavf/iavf_rxtx_vec_common.h +4 -2
@@ -187,8 +187,11 @@ _iavf_tx_queue_release_mbufs_vec(struct
 iavf_tx_queue *txq)
 
 	i = txq->next_dd - txq->rs_thresh + 1;
 	while (i != txq->tx_tail) {
-		rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
-		txq->sw_ring[i].mbuf = NULL;
+		if (txq->sw_ring[i].mbuf) {
+			rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
+			txq->sw_ring[i].mbuf = NULL;
+		}

Could you explain how to reproduce this issue in the commit log.

Looks like it is to fix the scenario that queue stop and start again and some mbuf will be double free at some time?

Quoted 6 lines
drivers/net/iavf/iavf_rxtx_vec_common.h +1 -0
+
 		if (++i == txq->nb_tx_desc)
 			i = 0;

}
--
2.34.1

#2 lore raw

PATCH v2 1/1 net/iavf: fix coredump when exiting testpmd

In reply to Kaiwen Deng

Avf releasing mbuf using the vector path release API causes a coredump when the basic Tx path is selected. This commit changes to use the basic path release API when selecting the basic Tx path.

Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")
---
 drivers/net/iavf/iavf_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/iavf/iavf_rxtx.c +1 -0
index 610912f635..a16e03d88c 100644
@@ -4022,6 +4022,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				PMD_DRV_LOG(DEBUG,
 					"AVX2 does not support outer checksum offload, using Basic Tx (port %d).",
 					dev->data->port_id);
+				return;
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx2_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
Signature · 1 line
2.34.1
#3 lore raw

RE: [PATCH v2] net/iavf: fix coredump when exiting testpmd

Hi Kaiwen,

Quoted 10 lines

-----Original Message-----
From: Kaiwen Deng <[email protected]>
Sent: Wednesday, November 1, 2023 9:35 AM
To: [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: [PATCH v2] net/iavf: fix coredump when exiting testpmd

Quoted 4 lines

Avf releasing mbuf using the vector path release API causes a coredump when the basic Tx path is selected.
This commit changes to use the basic path release API when selecting the basic Tx path.

Sorry, don't catch the point.
I see you changed the code when selecting AVX2 non-offload path. Confused about what's " the vector path release API " and what's " the basic path release API ".

Quoted 24 lines
Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")
---
 drivers/net/iavf/iavf_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/iavf/iavf_rxtx.c index renamed from drivers/net/iavf/iavf_rxtx.c +0 -0

610912f635..a16e03d88c 100644

drivers/net/iavf/iavf_rxtx.c +1 -0
@@ -4022,6 +4022,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				PMD_DRV_LOG(DEBUG,
 					"AVX2 does not support outer checksum offload,
 using Basic Tx (port %d).",
 					dev->data->port_id);
+				return;
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx2_offload;

dev->tx_pkt_prepare = iavf_prep_pkts;
--
2.34.1

#4 lore raw

RE: [PATCH v2] net/iavf: fix coredump when exiting testpmd

Quoted 25 lines

-----Original Message-----
From: Lu, Wenzhuo <[email protected]>
Sent: Wednesday, November 1, 2023 3:53 PM
To: Deng, KaiwenX <[email protected]>; [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: RE: [PATCH v2] net/iavf: fix coredump when exiting testpmd

Hi Kaiwen,

Quoted 11 lines

-----Original Message-----
From: Kaiwen Deng <[email protected]>
Sent: Wednesday, November 1, 2023 9:35 AM
To: [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: [PATCH v2] net/iavf: fix coredump when exiting testpmd

Quoted 9 lines
Quoted 4 lines

Avf releasing mbuf using the vector path release API causes a coredump when the basic Tx path is selected.
This commit changes to use the basic path release API when selecting the basic Tx path.

Sorry, don't catch the point.
I see you changed the code when selecting AVX2 non-offload path. Confused about what's " the vector path release API " and what's " the basic path release API ".

Hi Wenzhuo:

Thanks for your review.
According to the code below.
"the vector path release API" is iavf_tx_queue_release_mbufs_sse. "the basic path release API" is release_txq_mbufs.

static const
struct iavf_txq_ops iavf_txq_release_mbufs_ops[] = {
[IAVF_REL_MBUFS_DEFAULT].release_mbufs = release_txq_mbufs,
#ifdef RTE_ARCH_X86
[IAVF_REL_MBUFS_SSE_VEC].release_mbufs = iavf_tx_queue_release_mbufs_sse,

#ifdef CC_AVX512_SUPPORT
	[IAVF_REL_MBUFS_AVX512_VEC].release_mbufs = iavf_tx_queue_release_mbufs_avx512,

#endif

Quoted 26 lines
Quoted 14 lines
Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")
---
 drivers/net/iavf/iavf_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/drivers/net/iavf/iavf_rxtx.c index 610912f635..a16e03d88c 100644

drivers/net/iavf/iavf_rxtx.c iavf_set_tx_function(struct rte_eth_dev *dev) · line 4023

Quoted 2 lines
drivers/net/iavf/iavf_rxtx.c +0 -0
@@ -4022,6 +4022,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				PMD_DRV_LOG(DEBUG,
 					"AVX2 does not support outer

checksum offload, using Basic Tx

drivers/net/iavf/iavf_rxtx.c iavf_set_tx_function(struct rte_eth_dev *dev)

Quoted 5 lines
drivers/net/iavf/iavf_rxtx.c +1 -0
 (port %d).",
 					dev->data->port_id);
+				return;
 			} else {
 				dev->tx_pkt_burst =

iavf_xmit_pkts_vec_avx2_offload;

Quoted 3 lines

dev->tx_pkt_prepare = iavf_prep_pkts;
--
2.34.1

#5 lore raw

RE: [PATCH v2] net/iavf: fix coredump when exiting testpmd

In reply to Kaiwen Deng
Quoted 11 lines

-----Original Message-----
From: Kaiwen Deng <[email protected]>
Sent: Wednesday, November 1, 2023 9:35 AM
To: [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: [PATCH v2] net/iavf: fix coredump when exiting testpmd

please remove testpmd from the title if this issue is not specific to testpmd.

You can always add reproduce step with testpmd in commit log.

Quoted 30 lines

Avf releasing mbuf using the vector path release API causes a coredump when the basic Tx path is selected.
This commit changes to use the basic path release API when selecting the basic Tx path.

Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")
---
 drivers/net/iavf/iavf_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/iavf/iavf_rxtx.c index renamed from drivers/net/iavf/iavf_rxtx.c +0 -0

610912f635..a16e03d88c 100644

drivers/net/iavf/iavf_rxtx.c +1 -0
@@ -4022,6 +4022,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				PMD_DRV_LOG(DEBUG,
 					"AVX2 does not support outer
 checksum offload, using Basic Tx (port %d).",
 					dev->data->port_id);
+				return;
 			} else {
 				dev->tx_pkt_burst =

iavf_xmit_pkts_vec_avx2_offload;
dev->tx_pkt_prepare = iavf_prep_pkts;
--
2.34.1

#6 lore raw

PATCH v3 1/1 net/iavf: fix mbuf release API selection

In reply to Kaiwen Deng

When AVX2 is forcibly selected and outer checksum offload is configured, the basic Tx path will be selected. Also, the txq mbuf release API is incorrectly set to iavf_tx_queue_release_mbufs_sse. This causes coredump.

This commit selects release_txq_mbufs to releasing txq mbufs when selecting the basic Tx path.

Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")
---
 drivers/net/iavf/iavf_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/iavf/iavf_rxtx.c +1 -0
index 610912f635..a16e03d88c 100644
@@ -4022,6 +4022,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				PMD_DRV_LOG(DEBUG,
 					"AVX2 does not support outer checksum offload, using Basic Tx (port %d).",
 					dev->data->port_id);
+				return;
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx2_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
Signature · 1 line
2.34.1
#7 lore raw

RE: [PATCH v3] net/iavf: fix mbuf release API selection

Quoted 32 lines

-----Original Message-----
From: Kaiwen Deng <[email protected]>
Sent: Thursday, November 2, 2023 12:43 PM
To: [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: [PATCH v3] net/iavf: fix mbuf release API selection

When AVX2 is forcibly selected and outer checksum offload is configured, the basic Tx path will be selected. Also, the txq mbuf release API is incorrectly set to iavf_tx_queue_release_mbufs_sse. This causes coredump.

This commit selects release_txq_mbufs to releasing txq mbufs when selecting the basic Tx path.

Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")
---
 drivers/net/iavf/iavf_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/iavf/iavf_rxtx.c index renamed from drivers/net/iavf/iavf_rxtx.c +0 -0

610912f635..a16e03d88c 100644

drivers/net/iavf/iavf_rxtx.c iavf_set_tx_function(struct rte_eth_dev *dev) · line 4026

Quoted 5 lines
drivers/net/iavf/iavf_rxtx.c +1 -0
@@ -4022,6 +4022,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				PMD_DRV_LOG(DEBUG,
 					"AVX2 does not support outer
 checksum offload, using Basic Tx (port %d).",
 					dev->data->port_id);
+				return;

This make the execution routing not consistent between avx2 and avx512.
I think it will be a better solution if we reset the use_avx2 flag here, and use this flag to decide if need to overwrite the release function later.

Quoted 6 lines
drivers/net/iavf/iavf_rxtx.c +0 -0
 			} else {
 				dev->tx_pkt_burst =

iavf_xmit_pkts_vec_avx2_offload;
dev->tx_pkt_prepare = iavf_prep_pkts;
--
2.34.1

#8 lore raw

RE: [PATCH v3] net/iavf: fix mbuf release API selection

Quoted 41 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Wednesday, November 8, 2023 5:33 PM
To: Deng, KaiwenX <[email protected]>; [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: RE: [PATCH v3] net/iavf: fix mbuf release API selection

Quoted 11 lines

-----Original Message-----
From: Kaiwen Deng <[email protected]>
Sent: Thursday, November 2, 2023 12:43 PM
To: [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: [PATCH v3] net/iavf: fix mbuf release API selection

Quoted 3 lines

When AVX2 is forcibly selected and outer checksum offload is configured, the basic Tx path will be selected. Also, the txq mbuf release API is incorrectly set to iavf_tx_queue_release_mbufs_sse. This

causes coredump.

Quoted 12 lines

This commit selects release_txq_mbufs to releasing txq mbufs when selecting the basic Tx path.

Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")
---
 drivers/net/iavf/iavf_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

drivers/net/iavf/iavf_rxtx.c iavf_set_tx_function(struct rte_eth_dev *dev) · line 4026

Quoted 10 lines
(quoted diff) +0 -0

b/drivers/net/iavf/iavf_rxtx.c index 610912f635..a16e03d88c 100644

drivers/net/iavf/iavf_rxtx.c +1 -0
@@ -4022,6 +4022,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				PMD_DRV_LOG(DEBUG,
 					"AVX2 does not support outer
 checksum offload, using Basic Tx (port %d).",
 					dev->data->port_id);
+				return;

This make the execution routing not consistent between avx2 and avx512. I think it will be a better solution if we reset the use_avx2 flag here, and use this flag to decide if need to overwrite the release function later.

Or you can just "goto normal" and removing function call assignment.

Quoted 7 lines
Quoted 7 lines
drivers/net/iavf/iavf_rxtx.c +0 -0
 			} else {
 				dev->tx_pkt_burst =

iavf_xmit_pkts_vec_avx2_offload;
dev->tx_pkt_prepare = iavf_prep_pkts;
--
2.34.1

#9 lore raw

RE: [PATCH v3] net/iavf: fix mbuf release API selection

Quoted 70 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Wednesday, November 8, 2023 8:03 PM
To: Zhang, Qi Z <[email protected]>; Deng, KaiwenX <[email protected]>; [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: RE: [PATCH v3] net/iavf: fix mbuf release API selection

Quoted 41 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Wednesday, November 8, 2023 5:33 PM
To: Deng, KaiwenX <[email protected]>; [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: RE: [PATCH v3] net/iavf: fix mbuf release API selection

Quoted 11 lines

-----Original Message-----
From: Kaiwen Deng <[email protected]>
Sent: Thursday, November 2, 2023 12:43 PM
To: [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: [PATCH v3] net/iavf: fix mbuf release API selection

Quoted 4 lines

When AVX2 is forcibly selected and outer checksum offload is configured, the basic Tx path will be selected. Also, the txq mbuf release API is incorrectly set to iavf_tx_queue_release_mbufs_sse. This

causes coredump.

Quoted 12 lines

This commit selects release_txq_mbufs to releasing txq mbufs when selecting the basic Tx path.

Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")
---
 drivers/net/iavf/iavf_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

drivers/net/iavf/iavf_rxtx.c iavf_set_tx_function(struct rte_eth_dev *dev) · line 4026

Quoted 10 lines
(quoted diff) +0 -0

b/drivers/net/iavf/iavf_rxtx.c index 610912f635..a16e03d88c 100644

drivers/net/iavf/iavf_rxtx.c +1 -0
@@ -4022,6 +4022,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				PMD_DRV_LOG(DEBUG,
 					"AVX2 does not support outer
 checksum offload, using Basic Tx (port %d).",
 					dev->data->port_id);
+				return;

This make the execution routing not consistent between avx2 and avx512. I think it will be a better solution if we reset the use_avx2 flag here, and use this flag to decide if need to overwrite the release function

Quoted 3 lines

later.

Or you can just "goto normal" and removing function call assignment.

I will prepare a new patch.
Thanks.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/iavf/iavf_rxtx.c +0 -0
 			} else {
 				dev->tx_pkt_burst =

iavf_xmit_pkts_vec_avx2_offload;
dev->tx_pkt_prepare = iavf_prep_pkts;
--
2.34.1

#10 lore raw

PATCH v4 1/1 net/iavf: fix mbuf release API selection

In reply to Kaiwen Deng

When AVX2 is forcibly selected and outer checksum offload is configured, the basic Tx path will be selected. Also, the txq mbuf release API is incorrectly set to iavf_tx_queue_release_mbufs_sse. This causes coredump.

This commit selects release_txq_mbufs to releasing txq mbufs when selecting the basic Tx path.

Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")
---
 drivers/net/iavf/iavf_rxtx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/iavf/iavf_rxtx.c +2 -4
index 45f638c1d2..f19aa14646 100644
@@ -4018,11 +4018,9 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				PMD_DRV_LOG(DEBUG, "Using AVX2 Vector Tx (port %d).",
 					    dev->data->port_id);
 			} else if (check_ret == IAVF_VECTOR_CTX_OFFLOAD_PATH) {
-				dev->tx_pkt_burst = iavf_xmit_pkts;
-				dev->tx_pkt_prepare = iavf_prep_pkts;
 				PMD_DRV_LOG(DEBUG,
-					"AVX2 does not support outer checksum offload, using Basic Tx (port %d).",
-					dev->data->port_id);
+					"AVX2 does not support outer checksum offload.");
+				goto normal;
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx2_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
Signature · 1 line
2.34.1
Acked-by on v4 1/1 Applied
#11 lore raw

RE: [PATCH v4] net/iavf: fix mbuf release API selection

Quoted 16 lines

-----Original Message-----
From: Kaiwen Deng <[email protected]>
Sent: Thursday, November 9, 2023 12:59 PM
To: [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhou, YidingX <[email protected]>; Deng, KaiwenX <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zeng, ZhichaoX <[email protected]>
Subject: [PATCH v4] net/iavf: fix mbuf release API selection

When AVX2 is forcibly selected and outer checksum offload is configured, the basic Tx path will be selected. Also, the txq mbuf release API is incorrectly set to iavf_tx_queue_release_mbufs_sse. This causes coredump.

Quoted 7 lines

This commit selects release_txq_mbufs to releasing txq mbufs when selecting the basic Tx path.

Fixes 22f1e7608ebc ("net/iavf: fix AVX2 Tx selection")

Applied to dpdk-next-net-intel.

Thanks
Qi