Skip to contentSkip to conversation

delete HW rings when releasing queues

PATCH Superseded Yunjian Wang 4 participants 30 messages Sep 17, 2021 – Oct 7, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

cover delete HW rings when releasing queues

This series for deleting HW rings when releasing queues for igb, ixgbe, i40e, ice & em drivers.

Yunjian Wang (4):
net/e1000: delete HW rings when releasing queues net/ice: delete HW rings when releasing queues net/i40e: delete HW rings when releasing queues net/ixgbe: delete HW rings when releasing queues

 drivers/net/e1000/em_rxtx.c    | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c   | 9 +++++++--
 drivers/net/i40e/i40e_fdir.c   | 3 ---
 drivers/net/i40e/i40e_rxtx.c   | 8 ++++++--
 drivers/net/i40e/i40e_rxtx.h   | 2 ++
 drivers/net/ice/ice_rxtx.c     | 6 ++++--
 drivers/net/ice/ice_rxtx.h     | 2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 9 files changed, 33 insertions(+), 13 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/4 net/e1000: delete HW rings when releasing queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:
- rte_eth_bond_slave_remove
- rte_eth_dev_internal_reset
- eth_dev_rx_queue_config
- dev_rx_queue_release
- dev_close
- dev_free_queues

In order to free the memzone, we can release the memzone when releasing queues.

---
 drivers/net/e1000/em_rxtx.c  | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/net/e1000/em_rxtx.c +6 -2
index dfd8f2fd00..82928083f5 100644
@@ -104,6 +104,7 @@ struct em_rx_queue {
 	uint8_t             hthresh;    /**< Host threshold register. */
 	uint8_t             wthresh;    /**< Write-back threshold register. */
 	uint8_t             crc_len;    /**< 0 if CRC stripped, 4 otherwise. */
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -173,6 +174,7 @@ struct em_tx_queue {
 	struct em_ctx_info ctx_cache;
 	/**< Hardware context history.*/
 	uint64_t	       offloads; /**< offloads of DEV_TX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 #if 1
@@ -1116,6 +1118,7 @@ em_tx_queue_release(struct em_tx_queue *txq)
 	if (txq != NULL) {
 		em_tx_queue_release_mbufs(txq);
 		rte_free(txq->sw_ring);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -1286,6 +1289,7 @@ eth_em_tx_queue_setup(struct rte_eth_dev *dev,
 			RTE_CACHE_LINE_SIZE)) == NULL)
 		return -ENOMEM;
 
+	txq->mz = tz;
 	/* Allocate software ring */
 	if ((txq->sw_ring = rte_zmalloc("txq->sw_ring",
 			sizeof(txq->sw_ring[0]) * nb_desc,
@@ -1338,6 +1342,7 @@ em_rx_queue_release(struct em_rx_queue *rxq)
 	if (rxq != NULL) {
 		em_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -1452,6 +1457,7 @@ eth_em_rx_queue_setup(struct rte_eth_dev *dev,
 			RTE_CACHE_LINE_SIZE)) == NULL)
 		return -ENOMEM;
 
+	rxq->mz = rz;
 	/* Allocate software ring. */
 	if ((rxq->sw_ring = rte_zmalloc("rxq->sw_ring",
 			sizeof (rxq->sw_ring[0]) * nb_desc,
@@ -1611,14 +1617,12 @@ em_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		eth_em_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		eth_em_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
drivers/net/e1000/igb_rxtx.c +7 -2
index 278d5d2712..dc0de37246 100644
@@ -112,6 +112,7 @@ struct igb_rx_queue {
 	uint8_t             drop_en;  /**< If not 0, set SRRCTL.Drop_En. */
 	uint32_t            flags;      /**< RX flags. */
 	uint64_t	    offloads;   /**< offloads of DEV_RX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -186,6 +187,7 @@ struct igb_tx_queue {
 	struct igb_advctx_info ctx_cache[IGB_CTX_NUM];
 	/**< Hardware context history.*/
 	uint64_t	       offloads; /**< offloads of DEV_TX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 #if 1
@@ -1276,6 +1278,7 @@ igb_tx_queue_release(struct igb_tx_queue *txq)
 	if (txq != NULL) {
 		igb_tx_queue_release_mbufs(txq);
 		rte_free(txq->sw_ring);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -1545,6 +1548,7 @@ eth_igb_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->pthresh = tx_conf->tx_thresh.pthresh;
 	txq->hthresh = tx_conf->tx_thresh.hthresh;
@@ -1601,6 +1605,7 @@ igb_rx_queue_release(struct igb_rx_queue *rxq)
 	if (rxq != NULL) {
 		igb_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -1746,6 +1751,8 @@ eth_igb_rx_queue_setup(struct rte_eth_dev *dev,
 		igb_rx_queue_release(rxq);
 		return -ENOMEM;
 	}
+
+	rxq->mz = rz;
 	rxq->rdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDT(rxq->reg_idx));
 	rxq->rdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDH(rxq->reg_idx));
 	rxq->rx_ring_phys_addr = rz->iova;
@@ -1885,14 +1892,12 @@ igb_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		eth_igb_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		eth_igb_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
Signature · 1 line
2.23.0
#2 lore raw

PATCH 2/4 net/ice: delete HW rings when releasing queues

In reply to Yunjian Wang

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:
- rte_eth_bond_slave_remove
- rte_eth_dev_internal_reset
- eth_dev_rx_queue_config
- dev_rx_queue_release
- dev_close
- dev_free_queues

In order to free the memzone, we can release the memzone when releasing queues.

---
 drivers/net/ice/ice_rxtx.c | 6 ++++--
 drivers/net/ice/ice_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/ice/ice_rxtx.c +4 -2
index 5d7ab4f047..472da6bf83 100644
@@ -1135,6 +1135,7 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/* Zero all the descriptors in the ring. */
 	memset(rz->addr, 0, ring_size);
 
@@ -1190,6 +1191,7 @@ ice_rx_queue_release(void *rxq)
 
 	q->rx_rel_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -1336,6 +1338,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -1386,6 +1389,7 @@ ice_tx_queue_release(void *txq)
 
 	q->tx_rel_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -2080,7 +2084,6 @@ ice_free_queues(struct rte_eth_dev *dev)
 			continue;
 		ice_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
@@ -2089,7 +2092,6 @@ ice_free_queues(struct rte_eth_dev *dev)
 			continue;
 		ice_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
drivers/net/ice/ice_rxtx.h +2 -0
index b10db0874d..903c99a640 100644
@@ -89,6 +89,7 @@ struct ice_rx_queue {
 	ice_rxd_to_pkt_fields_t rxd_to_pkt_fields; /* handle FlexiMD by RXDID */
 	ice_rx_release_mbufs_t rx_rel_mbufs;
 	uint64_t offloads;
+	const struct rte_memzone *mz;
 };
 
 struct ice_tx_entry {
@@ -133,6 +134,7 @@ struct ice_tx_queue {
 	bool tx_deferred_start; /* don't start this queue in dev start */
 	bool q_set; /* indicate if tx queue has been configured */
 	ice_tx_release_mbufs_t tx_rel_mbufs;
+	const struct rte_memzone *mz;
 };
 
 /* Offload features */
Signature · 1 line
2.23.0
#3 lore raw

PATCH 3/4 net/i40e: delete HW rings when releasing queues

In reply to Yunjian Wang

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:
- rte_eth_bond_slave_remove
- rte_eth_dev_internal_reset
- eth_dev_rx_queue_config
- dev_rx_queue_release
- dev_close
- dev_free_queues

In order to free the memzone, we can release the memzone when releasing queues.

---
 drivers/net/i40e/i40e_fdir.c | 3 ---
 drivers/net/i40e/i40e_rxtx.c | 8 ++++++--
 drivers/net/i40e/i40e_rxtx.h | 2 ++
 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_fdir.c +0 -3
index af075fda2a..e910346e4d 100644
@@ -284,7 +284,6 @@ i40e_fdir_teardown(struct i40e_pf *pf)
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi;
-	struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id];
 
 	vsi = pf->fdir.fdir_vsi;
 	if (!vsi)
@@ -301,10 +300,8 @@ i40e_fdir_teardown(struct i40e_pf *pf)
 	if (err)
 		PMD_DRV_LOG(DEBUG, "Failed to do FDIR RX switch off");
 
-	rte_eth_dma_zone_free(dev, "fdir_rx_ring", pf->fdir.rxq->queue_id);
 	i40e_dev_rx_queue_release(pf->fdir.rxq);
 	pf->fdir.rxq = NULL;
-	rte_eth_dma_zone_free(dev, "fdir_tx_ring", pf->fdir.txq->queue_id);
 	i40e_dev_tx_queue_release(pf->fdir.txq);
 	pf->fdir.txq = NULL;
 	i40e_vsi_release(vsi);
drivers/net/i40e/i40e_rxtx.c +6 -2
index 8329cbdd4e..b67eb1ee94 100644
@@ -2034,6 +2034,7 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/* Zero all the descriptors in the ring. */
 	memset(rz->addr, 0, ring_size);
 
@@ -2113,6 +2114,7 @@ i40e_dev_rx_queue_release(void *rxq)
 
 	i40e_rx_queue_release_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -2433,6 +2435,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -2506,6 +2509,7 @@ i40e_dev_tx_queue_release(void *txq)
 
 	i40e_tx_queue_release_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -3058,7 +3062,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
 			continue;
 		i40e_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
@@ -3066,7 +3069,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
 			continue;
 		i40e_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 }
 
@@ -3109,6 +3111,7 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
 		return I40E_ERR_NO_MEMORY;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = I40E_FDIR_NUM_TX_DESC;
 	txq->queue_id = I40E_FDIR_QUEUE_ID;
 	txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
@@ -3167,6 +3170,7 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
 		return I40E_ERR_NO_MEMORY;
 	}
 
+	rxq->mz = rz;
 	rxq->nb_rx_desc = I40E_FDIR_NUM_RX_DESC;
 	rxq->queue_id = I40E_FDIR_QUEUE_ID;
 	rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
drivers/net/i40e/i40e_rxtx.h +2 -0
index 5ccf5773e8..3c1a2fab89 100644
@@ -121,6 +121,7 @@ struct i40e_rx_queue {
 	uint16_t rx_using_sse; /**<flag indicate the usage of vPMD for rx */
 	uint8_t dcb_tc;         /**< Traffic class of rx queue */
 	uint64_t offloads; /**< Rx offload flags of DEV_RX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 struct i40e_tx_entry {
@@ -166,6 +167,7 @@ struct i40e_tx_queue {
 	bool tx_deferred_start; /**< don't start this queue in dev start */
 	uint8_t dcb_tc;         /**< Traffic class of tx queue */
 	uint64_t offloads; /**< Tx offload flags of DEV_RX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 /** Offload features */
Signature · 1 line
2.23.0
#4 lore raw

PATCH 4/4 net/ixgbe: delete HW rings when releasing queues

In reply to Yunjian Wang

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:
- rte_eth_bond_slave_remove
- rte_eth_dev_internal_reset
- eth_dev_rx_queue_config
- dev_rx_queue_release
- dev_close
- dev_free_queues

In order to free the memzone, we can release the memzone when releasing queues.

---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx.c +4 -2
index bfdfd5e755..1b6e0489f4 100644
@@ -2482,6 +2482,7 @@ ixgbe_tx_queue_release(struct ixgbe_tx_queue *txq)
 	if (txq != NULL && txq->ops != NULL) {
 		txq->ops->release_mbufs(txq);
 		txq->ops->free_swring(txq);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -2763,6 +2764,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -2887,6 +2889,7 @@ ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)
 		ixgbe_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
 		rte_free(rxq->sw_sc_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -3162,6 +3165,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/*
 	 * Zero init all the descriptors in the ring.
 	 */
@@ -3433,14 +3437,12 @@ ixgbe_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		ixgbe_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
drivers/net/ixgbe/ixgbe_rxtx.h +2 -0
index 476ef62cfd..a1764f2b08 100644
@@ -138,6 +138,7 @@ struct ixgbe_rx_queue {
 	struct rte_mbuf fake_mbuf;
 	/** hold packets to return to application */
 	struct rte_mbuf *rx_stage[RTE_PMD_IXGBE_RX_MAX_BURST*2];
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -236,6 +237,7 @@ struct ixgbe_tx_queue {
 	uint8_t		    using_ipsec;
 	/**< indicates that IPsec TX feature is in use */
 #endif
+	const struct rte_memzone *mz;
 };
 
 struct ixgbe_txq_ops {
Signature · 1 line
2.23.0
#5 lore raw

Re: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 9 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Friday, September 17, 2021 19:25
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>
Subject: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 10 lines

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:
- rte_eth_bond_slave_remove
- rte_eth_dev_internal_reset
- eth_dev_rx_queue_config
- dev_rx_queue_release
- dev_close
- dev_free_queues

What's these ops ? function call flow ? And where these names from ?

Quoted 9 lines

In order to free the memzone, we can release the memzone when releasing queues.

---

--
2.23.0

#6 lore raw

Re: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 31 lines

-----Original Message-----
From: Wang, Haiyue [mailto:[email protected]]
Sent: Friday, September 17, 2021 11:47 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 11 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Friday, September 17, 2021 19:25
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>
Subject: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 9 lines

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:
- rte_eth_bond_slave_remove
- rte_eth_dev_internal_reset
- eth_dev_rx_queue_config
- dev_rx_queue_release
- dev_close
- dev_free_queues

Quoted 1 line

What's these ops ? function call flow ? And where these names from ?

The above is simplified, and the original is:
rte_eth_bond_slave_remove
-->__eth_bond_slave_remove_lock_free
---->slave_remove
------> rte_eth_dev_internal_reset
--------> rte_eth_dev_rx_queue_config
----------> eth_dev_rx_queue_config
------------>i40e_dev_rx_queue_release
rte_eth_dev_close
-->i40e_dev_close
---->i40e_dev_free_queues
------>i40e_dev_rx_queue_release(not been called due to nb_rx_queues and nb_tx_queues are 0)

Quoted 10 lines
Quoted 10 lines

In order to free the memzone, we can release the memzone when releasing queues.

---

--
2.23.0

#7 lore raw

Re: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 41 lines

-----Original Message-----
From: wangyunjian <[email protected]>
Sent: Saturday, September 18, 2021 11:11
To: Wang, Haiyue <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 31 lines

-----Original Message-----
From: Wang, Haiyue [mailto:[email protected]]
Sent: Friday, September 17, 2021 11:47 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 11 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Friday, September 17, 2021 19:25
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>
Subject: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 9 lines

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:
- rte_eth_bond_slave_remove
- rte_eth_dev_internal_reset
- eth_dev_rx_queue_config
- dev_rx_queue_release
- dev_close
- dev_free_queues

Quoted 1 line

What's these ops ? function call flow ? And where these names from ?

Quoted 13 lines

The above is simplified, and the original is:
rte_eth_bond_slave_remove
-->__eth_bond_slave_remove_lock_free
---->slave_remove
------> rte_eth_dev_internal_reset
--------> rte_eth_dev_rx_queue_config
----------> eth_dev_rx_queue_config
------------>i40e_dev_rx_queue_release
rte_eth_dev_close
-->i40e_dev_close
---->i40e_dev_free_queues
------>i40e_dev_rx_queue_release(not been called due to nb_rx_queues and nb_tx_queues are 0)

Yeah, this is better.

The patch LGTM, and make sense.

Please update it as new commit message. Thanks!

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

In order to free the memzone, we can release the memzone when releasing queues.

---

--
2.23.0

#8 lore raw

v2 cover delete HW rings when releasing queues for some drivers

In reply to Yunjian Wang

This series for deleting HW rings when releasing queues for igb, ixgbe, i40e, ice & em drivers.

---
v2:
* Update commit log

Yunjian Wang (4):
net/e1000: delete HW rings when releasing queues net/ice: delete HW rings when releasing queues net/i40e: delete HW rings when releasing queues net/ixgbe: delete HW rings when releasing queues

 drivers/net/e1000/em_rxtx.c    | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c   | 9 +++++++--
 drivers/net/i40e/i40e_fdir.c   | 3 ---
 drivers/net/i40e/i40e_rxtx.c   | 8 ++++++--
 drivers/net/i40e/i40e_rxtx.h   | 2 ++
 drivers/net/ice/ice_rxtx.c     | 6 ++++--
 drivers/net/ice/ice_rxtx.h     | 2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 9 files changed, 33 insertions(+), 13 deletions(-)
Signature · 1 line
2.23.0
#9 lore raw

PATCH v2 1/4 net/e1000: delete HW rings when releasing queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>em_rx_queue_release
rte_eth_dev_close
-->eth_em_close
---->em_dev_free_queues
------>em_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

In order to free the memzone, we can release the memzone when releasing queues.

---
 drivers/net/e1000/em_rxtx.c  | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/net/e1000/em_rxtx.c +6 -2
index dfd8f2fd00..82928083f5 100644
@@ -104,6 +104,7 @@ struct em_rx_queue {
 	uint8_t             hthresh;    /**< Host threshold register. */
 	uint8_t             wthresh;    /**< Write-back threshold register. */
 	uint8_t             crc_len;    /**< 0 if CRC stripped, 4 otherwise. */
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -173,6 +174,7 @@ struct em_tx_queue {
 	struct em_ctx_info ctx_cache;
 	/**< Hardware context history.*/
 	uint64_t	       offloads; /**< offloads of DEV_TX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 #if 1
@@ -1116,6 +1118,7 @@ em_tx_queue_release(struct em_tx_queue *txq)
 	if (txq != NULL) {
 		em_tx_queue_release_mbufs(txq);
 		rte_free(txq->sw_ring);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -1286,6 +1289,7 @@ eth_em_tx_queue_setup(struct rte_eth_dev *dev,
 			RTE_CACHE_LINE_SIZE)) == NULL)
 		return -ENOMEM;
 
+	txq->mz = tz;
 	/* Allocate software ring */
 	if ((txq->sw_ring = rte_zmalloc("txq->sw_ring",
 			sizeof(txq->sw_ring[0]) * nb_desc,
@@ -1338,6 +1342,7 @@ em_rx_queue_release(struct em_rx_queue *rxq)
 	if (rxq != NULL) {
 		em_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -1452,6 +1457,7 @@ eth_em_rx_queue_setup(struct rte_eth_dev *dev,
 			RTE_CACHE_LINE_SIZE)) == NULL)
 		return -ENOMEM;
 
+	rxq->mz = rz;
 	/* Allocate software ring. */
 	if ((rxq->sw_ring = rte_zmalloc("rxq->sw_ring",
 			sizeof (rxq->sw_ring[0]) * nb_desc,
@@ -1611,14 +1617,12 @@ em_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		eth_em_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		eth_em_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
drivers/net/e1000/igb_rxtx.c +7 -2
index 278d5d2712..dc0de37246 100644
@@ -112,6 +112,7 @@ struct igb_rx_queue {
 	uint8_t             drop_en;  /**< If not 0, set SRRCTL.Drop_En. */
 	uint32_t            flags;      /**< RX flags. */
 	uint64_t	    offloads;   /**< offloads of DEV_RX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -186,6 +187,7 @@ struct igb_tx_queue {
 	struct igb_advctx_info ctx_cache[IGB_CTX_NUM];
 	/**< Hardware context history.*/
 	uint64_t	       offloads; /**< offloads of DEV_TX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 #if 1
@@ -1276,6 +1278,7 @@ igb_tx_queue_release(struct igb_tx_queue *txq)
 	if (txq != NULL) {
 		igb_tx_queue_release_mbufs(txq);
 		rte_free(txq->sw_ring);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -1545,6 +1548,7 @@ eth_igb_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->pthresh = tx_conf->tx_thresh.pthresh;
 	txq->hthresh = tx_conf->tx_thresh.hthresh;
@@ -1601,6 +1605,7 @@ igb_rx_queue_release(struct igb_rx_queue *rxq)
 	if (rxq != NULL) {
 		igb_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -1746,6 +1751,8 @@ eth_igb_rx_queue_setup(struct rte_eth_dev *dev,
 		igb_rx_queue_release(rxq);
 		return -ENOMEM;
 	}
+
+	rxq->mz = rz;
 	rxq->rdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDT(rxq->reg_idx));
 	rxq->rdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDH(rxq->reg_idx));
 	rxq->rx_ring_phys_addr = rz->iova;
@@ -1885,14 +1892,12 @@ igb_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		eth_igb_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		eth_igb_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
Signature · 1 line
2.23.0
#10 lore raw

PATCH v2 2/4 net/ice: delete HW rings when releasing queues

In reply to Yunjian Wang

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ice_rx_queue_release
rte_eth_dev_close
-->ice_dev_close
---->ice_free_queues
------>ice_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

In order to free the memzone, we can release the memzone when releasing queues.

---
 drivers/net/ice/ice_rxtx.c | 6 ++++--
 drivers/net/ice/ice_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/ice/ice_rxtx.c +4 -2
index 5d7ab4f047..472da6bf83 100644
@@ -1135,6 +1135,7 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/* Zero all the descriptors in the ring. */
 	memset(rz->addr, 0, ring_size);
 
@@ -1190,6 +1191,7 @@ ice_rx_queue_release(void *rxq)
 
 	q->rx_rel_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -1336,6 +1338,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -1386,6 +1389,7 @@ ice_tx_queue_release(void *txq)
 
 	q->tx_rel_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -2080,7 +2084,6 @@ ice_free_queues(struct rte_eth_dev *dev)
 			continue;
 		ice_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
@@ -2089,7 +2092,6 @@ ice_free_queues(struct rte_eth_dev *dev)
 			continue;
 		ice_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
drivers/net/ice/ice_rxtx.h +2 -0
index b10db0874d..903c99a640 100644
@@ -89,6 +89,7 @@ struct ice_rx_queue {
 	ice_rxd_to_pkt_fields_t rxd_to_pkt_fields; /* handle FlexiMD by RXDID */
 	ice_rx_release_mbufs_t rx_rel_mbufs;
 	uint64_t offloads;
+	const struct rte_memzone *mz;
 };
 
 struct ice_tx_entry {
@@ -133,6 +134,7 @@ struct ice_tx_queue {
 	bool tx_deferred_start; /* don't start this queue in dev start */
 	bool q_set; /* indicate if tx queue has been configured */
 	ice_tx_release_mbufs_t tx_rel_mbufs;
+	const struct rte_memzone *mz;
 };
 
 /* Offload features */
Signature · 1 line
2.23.0
#11 lore raw

PATCH v2 3/4 net/i40e: delete HW rings when releasing queues

In reply to Yunjian Wang

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>i40e_dev_rx_queue_release rte_eth_dev_close
-->i40e_dev_close
---->i40e_dev_free_queues ------>i40e_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

In order to free the memzone, we can release the memzone when releasing queues.

---
 drivers/net/i40e/i40e_fdir.c | 3 ---
 drivers/net/i40e/i40e_rxtx.c | 8 ++++++--
 drivers/net/i40e/i40e_rxtx.h | 2 ++
 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_fdir.c +0 -3
index af075fda2a..e910346e4d 100644
@@ -284,7 +284,6 @@ i40e_fdir_teardown(struct i40e_pf *pf)
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi;
-	struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id];
 
 	vsi = pf->fdir.fdir_vsi;
 	if (!vsi)
@@ -301,10 +300,8 @@ i40e_fdir_teardown(struct i40e_pf *pf)
 	if (err)
 		PMD_DRV_LOG(DEBUG, "Failed to do FDIR RX switch off");
 
-	rte_eth_dma_zone_free(dev, "fdir_rx_ring", pf->fdir.rxq->queue_id);
 	i40e_dev_rx_queue_release(pf->fdir.rxq);
 	pf->fdir.rxq = NULL;
-	rte_eth_dma_zone_free(dev, "fdir_tx_ring", pf->fdir.txq->queue_id);
 	i40e_dev_tx_queue_release(pf->fdir.txq);
 	pf->fdir.txq = NULL;
 	i40e_vsi_release(vsi);
drivers/net/i40e/i40e_rxtx.c +6 -2
index 8329cbdd4e..b67eb1ee94 100644
@@ -2034,6 +2034,7 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/* Zero all the descriptors in the ring. */
 	memset(rz->addr, 0, ring_size);
 
@@ -2113,6 +2114,7 @@ i40e_dev_rx_queue_release(void *rxq)
 
 	i40e_rx_queue_release_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -2433,6 +2435,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -2506,6 +2509,7 @@ i40e_dev_tx_queue_release(void *txq)
 
 	i40e_tx_queue_release_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -3058,7 +3062,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
 			continue;
 		i40e_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
@@ -3066,7 +3069,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
 			continue;
 		i40e_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 }
 
@@ -3109,6 +3111,7 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
 		return I40E_ERR_NO_MEMORY;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = I40E_FDIR_NUM_TX_DESC;
 	txq->queue_id = I40E_FDIR_QUEUE_ID;
 	txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
@@ -3167,6 +3170,7 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
 		return I40E_ERR_NO_MEMORY;
 	}
 
+	rxq->mz = rz;
 	rxq->nb_rx_desc = I40E_FDIR_NUM_RX_DESC;
 	rxq->queue_id = I40E_FDIR_QUEUE_ID;
 	rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
drivers/net/i40e/i40e_rxtx.h +2 -0
index 5ccf5773e8..3c1a2fab89 100644
@@ -121,6 +121,7 @@ struct i40e_rx_queue {
 	uint16_t rx_using_sse; /**<flag indicate the usage of vPMD for rx */
 	uint8_t dcb_tc;         /**< Traffic class of rx queue */
 	uint64_t offloads; /**< Rx offload flags of DEV_RX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 struct i40e_tx_entry {
@@ -166,6 +167,7 @@ struct i40e_tx_queue {
 	bool tx_deferred_start; /**< don't start this queue in dev start */
 	uint8_t dcb_tc;         /**< Traffic class of tx queue */
 	uint64_t offloads; /**< Tx offload flags of DEV_RX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 /** Offload features */
Signature · 1 line
2.23.0
#12 lore raw

PATCH v2 4/4 net/ixgbe: delete HW rings when releasing queues

In reply to Yunjian Wang

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ixgbe_dev_rx_queue_release rte_eth_dev_close
-->ixgbe_dev_close
---->ixgbe_dev_free_queues ------>ixgbe_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

In order to free the memzone, we can release the memzone when releasing queues.

---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx.c +4 -2
index bfdfd5e755..1b6e0489f4 100644
@@ -2482,6 +2482,7 @@ ixgbe_tx_queue_release(struct ixgbe_tx_queue *txq)
 	if (txq != NULL && txq->ops != NULL) {
 		txq->ops->release_mbufs(txq);
 		txq->ops->free_swring(txq);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -2763,6 +2764,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -2887,6 +2889,7 @@ ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)
 		ixgbe_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
 		rte_free(rxq->sw_sc_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -3162,6 +3165,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/*
 	 * Zero init all the descriptors in the ring.
 	 */
@@ -3433,14 +3437,12 @@ ixgbe_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		ixgbe_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
drivers/net/ixgbe/ixgbe_rxtx.h +2 -0
index 476ef62cfd..a1764f2b08 100644
@@ -138,6 +138,7 @@ struct ixgbe_rx_queue {
 	struct rte_mbuf fake_mbuf;
 	/** hold packets to return to application */
 	struct rte_mbuf *rx_stage[RTE_PMD_IXGBE_RX_MAX_BURST*2];
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -236,6 +237,7 @@ struct ixgbe_tx_queue {
 	uint8_t		    using_ipsec;
 	/**< indicates that IPsec TX feature is in use */
 #endif
+	const struct rte_memzone *mz;
 };
 
 struct ixgbe_txq_ops {
Signature · 1 line
2.23.0
#13 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 26 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Saturday, September 18, 2021 16:42
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>
Subject: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ixgbe_dev_rx_queue_release rte_eth_dev_close
-->ixgbe_dev_close
---->ixgbe_dev_free_queues ------>ixgbe_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

Quoted 3 lines

In order to free the memzone, we can release the memzone when releasing queues.

After re-check the eth dev API, I think we can simplify the commit message to such as:

Fix memzone leak when re-configure the RX/TX queues.

Please see 'rte_eth_dev_configure', when queue number is changed to small size, the BIG memzone queue index will be lost. This will make it is a MUST fix. ;-)

And add the Fixes tag and CC to stable.

What do you think ?

Quoted 79 lines
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx.c +4 -2
index bfdfd5e755..1b6e0489f4 100644
@@ -2482,6 +2482,7 @@ ixgbe_tx_queue_release(struct ixgbe_tx_queue *txq)
 	if (txq != NULL && txq->ops != NULL) {
 		txq->ops->release_mbufs(txq);
 		txq->ops->free_swring(txq);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -2763,6 +2764,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -2887,6 +2889,7 @@ ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)
 		ixgbe_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
 		rte_free(rxq->sw_sc_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -3162,6 +3165,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/*
 	 * Zero init all the descriptors in the ring.
 	 */
@@ -3433,14 +3437,12 @@ ixgbe_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		ixgbe_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
drivers/net/ixgbe/ixgbe_rxtx.h +2 -1
index 476ef62cfd..a1764f2b08 100644
@@ -138,6 +138,7 @@ struct ixgbe_rx_queue {
 	struct rte_mbuf fake_mbuf;
 	/** hold packets to return to application */
 	struct rte_mbuf *rx_stage[RTE_PMD_IXGBE_RX_MAX_BURST*2];
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -236,6 +237,7 @@ struct ixgbe_tx_queue {
 	uint8_t		    using_ipsec;
 	/**< indicates that IPsec TX feature is in use */
 #endif
+	const struct rte_memzone *mz;
 };
 
 struct ixgbe_txq_ops {
--

2.23.0

#14 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 46 lines

-----Original Message-----
From: Wang, Haiyue [mailto:[email protected]]
Sent: Wednesday, September 22, 2021 2:23 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 27 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Saturday, September 18, 2021 16:42
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>
Subject: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ixgbe_dev_rx_queue_release rte_eth_dev_close
-->ixgbe_dev_close
---->ixgbe_dev_free_queues ------>ixgbe_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

Quoted 3 lines

In order to free the memzone, we can release the memzone when releasing queues.

After re-check the eth dev API, I think we can simplify the commit message to such as:

Fix memzone leak when re-configure the RX/TX queues.

Quoted 7 lines

Please see 'rte_eth_dev_configure', when queue number is changed to small size, the BIG memzone queue index will be lost. This will make it is a MUST fix. ;-)

And add the Fixes tag and CC to stable.

What do you think ?

OK, thanks for your suggestion, will include them in next version.

Quoted 82 lines

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_tx_queue_release(struct ixgbe_tx_queue

Quoted 12 lines
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.c index bfdfd5e755..1b6e0489f4 100644

drivers/net/ixgbe/ixgbe_rxtx.c +0 -0
@@ -2482,6 +2482,7 @@ ixgbe_tx_queue_release(struct ixgbe_tx_queue

*txq)

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_tx_queue_setup(struct rte_eth_dev

Quoted 8 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 	if (txq != NULL && txq->ops != NULL) {
 		txq->ops->release_mbufs(txq);
 		txq->ops->free_swring(txq);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -2763,6 +2764,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev

*dev,

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_rx_queue_setup(struct rte_eth_dev

Quoted 16 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh; @@ -2887,6 +2889,7 @@

ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)

drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		ixgbe_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
 		rte_free(rxq->sw_sc_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -3162,6 +3165,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev

*dev,

Quoted 43 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -2
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/*
 	 * Zero init all the descriptors in the ring.
 	 */
@@ -3433,14 +3437,12 @@ ixgbe_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		ixgbe_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.h index 476ef62cfd..a1764f2b08 100644

drivers/net/ixgbe/ixgbe_rxtx.h +2 -1
@@ -138,6 +138,7 @@ struct ixgbe_rx_queue {
 	struct rte_mbuf fake_mbuf;
 	/** hold packets to return to application */
 	struct rte_mbuf *rx_stage[RTE_PMD_IXGBE_RX_MAX_BURST*2];
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -236,6 +237,7 @@ struct ixgbe_tx_queue {
 	uint8_t		    using_ipsec;
 	/**< indicates that IPsec TX feature is in use */  #endif
+	const struct rte_memzone *mz;
 };
 
 struct ixgbe_txq_ops {
--

2.23.0

#15 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 58 lines

-----Original Message-----
From: wangyunjian <[email protected]>
Sent: Wednesday, September 22, 2021 14:58
To: Wang, Haiyue <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 50 lines

-----Original Message-----
From: Wang, Haiyue [mailto:[email protected]]
Sent: Wednesday, September 22, 2021 2:23 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 27 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Saturday, September 18, 2021 16:42
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>
Subject: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ixgbe_dev_rx_queue_release rte_eth_dev_close
-->ixgbe_dev_close
---->ixgbe_dev_free_queues ------>ixgbe_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

Quoted 3 lines

In order to free the memzone, we can release the memzone when releasing queues.

After re-check the eth dev API, I think we can simplify the commit message to such as:

Fix memzone leak when re-configure the RX/TX queues.

Please see 'rte_eth_dev_configure', when queue number is changed to small size, the BIG memzone queue index will be lost. This will make it is a MUST fix. ;-)

Quoted 6 lines
Quoted 3 lines

And add the Fixes tag and CC to stable.

What do you think ?

OK, thanks for your suggestion, will include them in next version.

Also, please fix the patch format warnings. You can get this from patchwork CI.

FYI:

https://doc.dpdk.org/guides/contributing/patches.html

6.9. Checking the Patches

Quoted 82 lines
Quoted 82 lines

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_tx_queue_release(struct ixgbe_tx_queue

Quoted 12 lines
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.c index bfdfd5e755..1b6e0489f4 100644

drivers/net/ixgbe/ixgbe_rxtx.c +0 -0
@@ -2482,6 +2482,7 @@ ixgbe_tx_queue_release(struct ixgbe_tx_queue

*txq)

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_tx_queue_setup(struct rte_eth_dev

Quoted 8 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 	if (txq != NULL && txq->ops != NULL) {
 		txq->ops->release_mbufs(txq);
 		txq->ops->free_swring(txq);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -2763,6 +2764,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev

*dev,

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_rx_queue_setup(struct rte_eth_dev

Quoted 16 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh; @@ -2887,6 +2889,7 @@

ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)

drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		ixgbe_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
 		rte_free(rxq->sw_sc_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -3162,6 +3165,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev

*dev,

Quoted 43 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -2
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/*
 	 * Zero init all the descriptors in the ring.
 	 */
@@ -3433,14 +3437,12 @@ ixgbe_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		ixgbe_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.h index 476ef62cfd..a1764f2b08 100644

drivers/net/ixgbe/ixgbe_rxtx.h +2 -1
@@ -138,6 +138,7 @@ struct ixgbe_rx_queue {
 	struct rte_mbuf fake_mbuf;
 	/** hold packets to return to application */
 	struct rte_mbuf *rx_stage[RTE_PMD_IXGBE_RX_MAX_BURST*2];
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -236,6 +237,7 @@ struct ixgbe_tx_queue {
 	uint8_t		    using_ipsec;
 	/**< indicates that IPsec TX feature is in use */  #endif
+	const struct rte_memzone *mz;
 };
 
 struct ixgbe_txq_ops {
--

2.23.0

#16 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 79 lines

-----Original Message-----
From: Wang, Haiyue [mailto:[email protected]]
Sent: Wednesday, September 22, 2021 3:05 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 60 lines

-----Original Message-----
From: wangyunjian <[email protected]>
Sent: Wednesday, September 22, 2021 14:58
To: Wang, Haiyue <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 50 lines

-----Original Message-----
From: Wang, Haiyue [mailto:[email protected]]
Sent: Wednesday, September 22, 2021 2:23 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 27 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Saturday, September 18, 2021 16:42
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>
Subject: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ixgbe_dev_rx_queue_release rte_eth_dev_close
-->ixgbe_dev_close
---->ixgbe_dev_free_queues ------>ixgbe_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

Quoted 3 lines

In order to free the memzone, we can release the memzone when releasing queues.

After re-check the eth dev API, I think we can simplify the commit message to such as:

Fix memzone leak when re-configure the RX/TX queues.

Please see 'rte_eth_dev_configure', when queue number is changed to small size, the BIG memzone queue index will be lost. This will make it is a MUST fix. ;-)

Quoted 6 lines
Quoted 3 lines

And add the Fixes tag and CC to stable.

What do you think ?

OK, thanks for your suggestion, will include them in next version.

Quoted 7 lines

Also, please fix the patch format warnings. You can get this from patchwork CI.

FYI:

https://doc.dpdk.org/guides/contributing/patches.html

6.9. Checking the Patches

Thanks, I've seen it. It should be a report incorrectly.

http://mails.dpdk.org/archives/test-report/2021-September/220735.html

Test-Label: checkpatch
Test-Status: WARNING
http://dpdk.org/patch/99273

_coding style issues_

WARNING:TYPO_SPELLING: 'slave' may be misspelled - perhaps 'secondary'? #66:
rte_eth_bond_slave_remove

WARNING:TYPO_SPELLING: 'slave' may be misspelled - perhaps 'secondary'? #67:
-->__eth_bond_slave_remove_lock_free

WARNING:TYPO_SPELLING: 'slave' may be misspelled - perhaps 'secondary'? #68:
---->slave_remove

total: 0 errors, 3 warnings, 0 checks, 56 lines checked

Quoted 86 lines
Quoted 41 lines
Quoted 41 lines

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_tx_queue_release(struct ixgbe_tx_queue

Quoted 14 lines
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.c index bfdfd5e755..1b6e0489f4 100644

drivers/net/ixgbe/ixgbe_rxtx.c +0 -0
@@ -2482,6 +2482,7 @@ ixgbe_tx_queue_release(struct ixgbe_tx_queue

*txq)

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_tx_queue_setup(struct rte_eth_dev

Quoted 8 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 	if (txq != NULL && txq->ops != NULL) {
 		txq->ops->release_mbufs(txq);
 		txq->ops->free_swring(txq);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -2763,6 +2764,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev

*dev,

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_rx_queue_setup(struct rte_eth_dev

Quoted 16 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh; @@ -2887,6 +2889,7 @@

ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)

drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		ixgbe_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
 		rte_free(rxq->sw_sc_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -3162,6 +3165,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev

*dev,

Quoted 8 lines
Quoted 8 lines

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_free_queues(struct rte_eth_dev

Quoted 8 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/*
 	 * Zero init all the descriptors in the ring.
 	 */
@@ -3433,14 +3437,12 @@ ixgbe_dev_free_queues(struct rte_eth_dev

*dev)

Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
drivers/net/ixgbe/ixgbe_rxtx.c +0 -2
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		ixgbe_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.h index 476ef62cfd..a1764f2b08 100644

drivers/net/ixgbe/ixgbe_rxtx.h +2 -1
@@ -138,6 +138,7 @@ struct ixgbe_rx_queue {
 	struct rte_mbuf fake_mbuf;
 	/** hold packets to return to application */
 	struct rte_mbuf *rx_stage[RTE_PMD_IXGBE_RX_MAX_BURST*2];
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -236,6 +237,7 @@ struct ixgbe_tx_queue {
 	uint8_t		    using_ipsec;
 	/**< indicates that IPsec TX feature is in use */  #endif
+	const struct rte_memzone *mz;
 };
 
 struct ixgbe_txq_ops {
--

2.23.0

#17 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 114 lines

-----Original Message-----
From: wangyunjian <[email protected]>
Sent: Wednesday, September 22, 2021 19:14
To: Wang, Haiyue <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 77 lines

-----Original Message-----
From: Wang, Haiyue [mailto:[email protected]]
Sent: Wednesday, September 22, 2021 3:05 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 60 lines

-----Original Message-----
From: wangyunjian <[email protected]>
Sent: Wednesday, September 22, 2021 14:58
To: Wang, Haiyue <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 50 lines

-----Original Message-----
From: Wang, Haiyue [mailto:[email protected]]
Sent: Wednesday, September 22, 2021 2:23 PM
To: wangyunjian <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; dingxiaoxiong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Quoted 27 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Saturday, September 18, 2021 16:42
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>
Subject: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ixgbe_dev_rx_queue_release rte_eth_dev_close
-->ixgbe_dev_close
---->ixgbe_dev_free_queues ------>ixgbe_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

Quoted 3 lines

In order to free the memzone, we can release the memzone when releasing queues.

After re-check the eth dev API, I think we can simplify the commit message to such as:

Fix memzone leak when re-configure the RX/TX queues.

Please see 'rte_eth_dev_configure', when queue number is changed to small size, the BIG memzone queue index will be lost. This will make it is a MUST fix. ;-)

Quoted 6 lines
Quoted 3 lines

And add the Fixes tag and CC to stable.

What do you think ?

OK, thanks for your suggestion, will include them in next version.

Quoted 7 lines

Also, please fix the patch format warnings. You can get this from patchwork CI.

FYI:

https://doc.dpdk.org/guides/contributing/patches.html

6.9. Checking the Patches

Thanks, I've seen it. It should be a report incorrectly.

http://mails.dpdk.org/archives/test-report/2021-September/220735.html

Test-Label: checkpatch
Test-Status: WARNING
http://dpdk.org/patch/99273

_coding style issues_

WARNING:TYPO_SPELLING: 'slave' may be misspelled - perhaps 'secondary'? #66:
rte_eth_bond_slave_remove

WARNING:TYPO_SPELLING: 'slave' may be misspelled - perhaps 'secondary'? #67:
-->__eth_bond_slave_remove_lock_free

Quoted 6 lines

WARNING:TYPO_SPELLING: 'slave' may be misspelled - perhaps 'secondary'? #68:
---->slave_remove

total: 0 errors, 3 warnings, 0 checks, 56 lines checked

Yes, report incorrectly. After changed to new commit message, this will be gone. Thanks!

Quoted 86 lines
Quoted 86 lines
Quoted 41 lines
Quoted 41 lines

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_tx_queue_release(struct ixgbe_tx_queue

Quoted 14 lines
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.c index bfdfd5e755..1b6e0489f4 100644

drivers/net/ixgbe/ixgbe_rxtx.c +0 -0
@@ -2482,6 +2482,7 @@ ixgbe_tx_queue_release(struct ixgbe_tx_queue

*txq)

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_tx_queue_setup(struct rte_eth_dev

Quoted 8 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 	if (txq != NULL && txq->ops != NULL) {
 		txq->ops->release_mbufs(txq);
 		txq->ops->free_swring(txq);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -2763,6 +2764,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev

*dev,

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_rx_queue_setup(struct rte_eth_dev

Quoted 16 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh; @@ -2887,6 +2889,7 @@

ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)

drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		ixgbe_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
 		rte_free(rxq->sw_sc_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -3162,6 +3165,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev

*dev,

Quoted 8 lines
Quoted 8 lines

drivers/net/ixgbe/ixgbe_rxtx.c ixgbe_dev_free_queues(struct rte_eth_dev

Quoted 8 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -0
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/*
 	 * Zero init all the descriptors in the ring.
 	 */
@@ -3433,14 +3437,12 @@ ixgbe_dev_free_queues(struct rte_eth_dev

*dev)

Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
drivers/net/ixgbe/ixgbe_rxtx.c +0 -2
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		ixgbe_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.h index 476ef62cfd..a1764f2b08 100644

drivers/net/ixgbe/ixgbe_rxtx.h +2 -1
@@ -138,6 +138,7 @@ struct ixgbe_rx_queue {
 	struct rte_mbuf fake_mbuf;
 	/** hold packets to return to application */
 	struct rte_mbuf *rx_stage[RTE_PMD_IXGBE_RX_MAX_BURST*2];
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -236,6 +237,7 @@ struct ixgbe_tx_queue {
 	uint8_t		    using_ipsec;
 	/**< indicates that IPsec TX feature is in use */  #endif
+	const struct rte_memzone *mz;
 };
 
 struct ixgbe_txq_ops {
--

2.23.0

#18 lore raw

Re: [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers

In reply to Yunjian Wang
Quoted 14 lines · Yunjian Wang

This series for deleting HW rings when releasing queues for igb, ixgbe, i40e, ice & em drivers.

---
v2:
* Update commit log

Yunjian Wang (4):
net/e1000: delete HW rings when releasing queues net/ice: delete HW rings when releasing queues net/i40e: delete HW rings when releasing queues net/ixgbe: delete HW rings when releasing queues

Quoted 11 lines
 drivers/net/e1000/em_rxtx.c    | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c   | 9 +++++++--
 drivers/net/i40e/i40e_fdir.c   | 3 ---
 drivers/net/i40e/i40e_rxtx.c   | 8 ++++++--
 drivers/net/i40e/i40e_rxtx.h   | 2 ++
 drivers/net/ice/ice_rxtx.c     | 6 ++++--
 drivers/net/ice/ice_rxtx.h     | 2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 9 files changed, 33 insertions(+), 13 deletions(-)

- In net/ice (at least), the fdir rxq/txq memzones can be aligned on the same scheme.
Looking at the remaining drivers (net/cnxk, net/cxgbe and net/octeontx2), we could apply the same principle of keeping a reference to mz in internal driver structures.
Afterwards, I see no need to keep rte_eth_dma_zone_free() (it's internal, so we can remove and it's easy to re-add if a need arises).

Wdyt?

- Is this worth backporting to stable branches?

Signature · 1 line
David Marchand
#19 lore raw

Re: [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers

Quoted 45 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, September 20, 2021 15:25
To: Yunjian Wang <[email protected]>; Wang, Haiyue <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: dev <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Renata Saiakhova <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers

Quoted 14 lines · Yunjian Wang

This series for deleting HW rings when releasing queues for igb, ixgbe, i40e, ice & em drivers.

---
v2:
* Update commit log

Yunjian Wang (4):
net/e1000: delete HW rings when releasing queues net/ice: delete HW rings when releasing queues net/i40e: delete HW rings when releasing queues net/ixgbe: delete HW rings when releasing queues

Quoted 11 lines
 drivers/net/e1000/em_rxtx.c    | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c   | 9 +++++++--
 drivers/net/i40e/i40e_fdir.c   | 3 ---
 drivers/net/i40e/i40e_rxtx.c   | 8 ++++++--
 drivers/net/i40e/i40e_rxtx.h   | 2 ++
 drivers/net/ice/ice_rxtx.c     | 6 ++++--
 drivers/net/ice/ice_rxtx.h     | 2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 9 files changed, 33 insertions(+), 13 deletions(-)

- In net/ice (at least), the fdir rxq/txq memzones can be aligned on the same scheme.
Looking at the remaining drivers (net/cnxk, net/cxgbe and net/octeontx2), we could apply the same principle of keeping a reference to mz in internal driver structures.
Afterwards, I see no need to keep rte_eth_dma_zone_free() (it's internal, so we can remove and it's easy to re-add if a need arises).

Quoted 1 line

Wdyt?

Yes, this makes dma_zone management clean. And good for hotplug design.

Then the function 'rte_eth_dma_zone_reserve' can also be simplified, no need to lookup and check, just call 'rte_memzone_reserve_aligned' directly ?

	mz = rte_memzone_lookup(z_name);
	if (mz) {
		if ((socket_id != SOCKET_ID_ANY && socket_id != mz->socket_id) ||
				size > mz->len ||
				((uintptr_t)mz->addr & (align - 1)) != 0) {
			RTE_ETHDEV_LOG(ERR,
				"memzone %s does not justify the requested attributes\n",
				mz->name);
			return NULL;
		}

		return mz;
	}
Quoted 4 lines

- Is this worth backporting to stable branches?

+1

Quoted 3 lines

--
David Marchand

#20 lore raw

v3 cover fixes for intel drivers

In reply to Yunjian Wang

This series for fixing memzone leak when re-configure the RX/TX queues for igb, ixgbe, i40e, ice & em drivers.

---
v3:
* 1. Update commit log
* 2. And ice fdir rxq/txq memzones are freed
v2:
* Update commit log

Yunjian Wang (4):
net/e1000: fix memzone leak when re-configure the RX/TX queues net/ice: fix memzone leak when re-configure the RX/TX queues net/i40e: fix memzone leak when re-configure the RX/TX queues net/ixgbe: fix memzone leak when re-configure the RX/TX queues

 drivers/net/e1000/em_rxtx.c       | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c      | 9 +++++++--
 drivers/net/i40e/i40e_fdir.c      | 3 ---
 drivers/net/i40e/i40e_rxtx.c      | 8 ++++++--
 drivers/net/i40e/i40e_rxtx.h      | 2 ++
 drivers/net/ice/ice_fdir_filter.c | 2 --
 drivers/net/ice/ice_rxtx.c        | 8 ++++++--
 drivers/net/ice/ice_rxtx.h        | 2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c    | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h    | 2 ++
 10 files changed, 35 insertions(+), 15 deletions(-)
Signature · 1 line
2.23.0
#21 lore raw

PATCH v3 1/4 net/e1000: fix memzone leak when re-configure the RX/TX queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>em_rx_queue_release
rte_eth_dev_close
-->eth_em_close
---->em_dev_free_queues
------>em_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

And when queue number is changed to small size, the BIG memzone queue index will be lost. This will lead to a memory leak. So we should release the memzone when releasing queues.

Fixes 460d1679586e ("drivers/net: delete HW rings while freeing queues")
---
 drivers/net/e1000/em_rxtx.c  | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/net/e1000/em_rxtx.c +6 -2
index dfd8f2fd00..82928083f5 100644
@@ -104,6 +104,7 @@ struct em_rx_queue {
 	uint8_t             hthresh;    /**< Host threshold register. */
 	uint8_t             wthresh;    /**< Write-back threshold register. */
 	uint8_t             crc_len;    /**< 0 if CRC stripped, 4 otherwise. */
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -173,6 +174,7 @@ struct em_tx_queue {
 	struct em_ctx_info ctx_cache;
 	/**< Hardware context history.*/
 	uint64_t	       offloads; /**< offloads of DEV_TX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 #if 1
@@ -1116,6 +1118,7 @@ em_tx_queue_release(struct em_tx_queue *txq)
 	if (txq != NULL) {
 		em_tx_queue_release_mbufs(txq);
 		rte_free(txq->sw_ring);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -1286,6 +1289,7 @@ eth_em_tx_queue_setup(struct rte_eth_dev *dev,
 			RTE_CACHE_LINE_SIZE)) == NULL)
 		return -ENOMEM;
 
+	txq->mz = tz;
 	/* Allocate software ring */
 	if ((txq->sw_ring = rte_zmalloc("txq->sw_ring",
 			sizeof(txq->sw_ring[0]) * nb_desc,
@@ -1338,6 +1342,7 @@ em_rx_queue_release(struct em_rx_queue *rxq)
 	if (rxq != NULL) {
 		em_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -1452,6 +1457,7 @@ eth_em_rx_queue_setup(struct rte_eth_dev *dev,
 			RTE_CACHE_LINE_SIZE)) == NULL)
 		return -ENOMEM;
 
+	rxq->mz = rz;
 	/* Allocate software ring. */
 	if ((rxq->sw_ring = rte_zmalloc("rxq->sw_ring",
 			sizeof (rxq->sw_ring[0]) * nb_desc,
@@ -1611,14 +1617,12 @@ em_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		eth_em_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		eth_em_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
drivers/net/e1000/igb_rxtx.c +7 -2
index 278d5d2712..dc0de37246 100644
@@ -112,6 +112,7 @@ struct igb_rx_queue {
 	uint8_t             drop_en;  /**< If not 0, set SRRCTL.Drop_En. */
 	uint32_t            flags;      /**< RX flags. */
 	uint64_t	    offloads;   /**< offloads of DEV_RX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -186,6 +187,7 @@ struct igb_tx_queue {
 	struct igb_advctx_info ctx_cache[IGB_CTX_NUM];
 	/**< Hardware context history.*/
 	uint64_t	       offloads; /**< offloads of DEV_TX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 #if 1
@@ -1276,6 +1278,7 @@ igb_tx_queue_release(struct igb_tx_queue *txq)
 	if (txq != NULL) {
 		igb_tx_queue_release_mbufs(txq);
 		rte_free(txq->sw_ring);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -1545,6 +1548,7 @@ eth_igb_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->pthresh = tx_conf->tx_thresh.pthresh;
 	txq->hthresh = tx_conf->tx_thresh.hthresh;
@@ -1601,6 +1605,7 @@ igb_rx_queue_release(struct igb_rx_queue *rxq)
 	if (rxq != NULL) {
 		igb_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -1746,6 +1751,8 @@ eth_igb_rx_queue_setup(struct rte_eth_dev *dev,
 		igb_rx_queue_release(rxq);
 		return -ENOMEM;
 	}
+
+	rxq->mz = rz;
 	rxq->rdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDT(rxq->reg_idx));
 	rxq->rdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDH(rxq->reg_idx));
 	rxq->rx_ring_phys_addr = rz->iova;
@@ -1885,14 +1892,12 @@ igb_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		eth_igb_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		eth_igb_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
Signature · 1 line
2.23.0
Acked-by on v3 1/4
#22 lore raw

Re: [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues

Quoted 30 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Wednesday, September 22, 2021 21:28
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>em_rx_queue_release
rte_eth_dev_close
-->eth_em_close
---->em_dev_free_queues
------>em_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

And when queue number is changed to small size, the BIG memzone queue index will be lost. This will lead to a memory leak. So we should release the memzone when releasing queues.

Quoted 9 lines
Fixes 460d1679586e ("drivers/net: delete HW rings while freeing queues")
---
 drivers/net/e1000/em_rxtx.c  | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)
Quoted 2 lines

--
2.23.0

#23 lore raw

PATCH v3 2/4 net/ice: fix memzone leak when re-configure the RX/TX queues

In reply to Yunjian Wang

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ice_rx_queue_release
rte_eth_dev_close
-->ice_dev_close
---->ice_free_queues
------>ice_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

And when queue number is changed to small size, the BIG memzone queue index will be lost. This will lead to a memory leak. So we should release the memzone when releasing queues.

Fixes 460d1679586e ("drivers/net: delete HW rings while freeing queues")
---
 drivers/net/ice/ice_fdir_filter.c | 2 --
 drivers/net/ice/ice_rxtx.c        | 8 ++++++--
 drivers/net/ice/ice_rxtx.h        | 2 ++
 3 files changed, 8 insertions(+), 4 deletions(-)
drivers/net/ice/ice_fdir_filter.c +0 -2
index 7ba65b9b04..82adb1fc8b 100644
@@ -651,10 +651,8 @@ ice_fdir_teardown(struct ice_pf *pf)
 
 	ice_tx_queue_release(pf->fdir.txq);
 	pf->fdir.txq = NULL;
-	rte_eth_dma_zone_free(eth_dev, "fdir_tx_ring", ICE_FDIR_QUEUE_ID);
 	ice_rx_queue_release(pf->fdir.rxq);
 	pf->fdir.rxq = NULL;
-	rte_eth_dma_zone_free(eth_dev, "fdir_rx_ring", ICE_FDIR_QUEUE_ID);
 	ice_fdir_prof_rm_all(pf);
 	ice_fdir_prof_free(hw);
 	ice_release_vsi(vsi);
drivers/net/ice/ice_rxtx.c +6 -2
index 5d7ab4f047..2fc2883059 100644
@@ -1135,6 +1135,7 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/* Zero all the descriptors in the ring. */
 	memset(rz->addr, 0, ring_size);
 
@@ -1190,6 +1191,7 @@ ice_rx_queue_release(void *rxq)
 
 	q->rx_rel_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -1336,6 +1338,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -1386,6 +1389,7 @@ ice_tx_queue_release(void *txq)
 
 	q->tx_rel_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -2080,7 +2084,6 @@ ice_free_queues(struct rte_eth_dev *dev)
 			continue;
 		ice_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
@@ -2089,7 +2092,6 @@ ice_free_queues(struct rte_eth_dev *dev)
 			continue;
 		ice_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
@@ -2136,6 +2138,7 @@ ice_fdir_setup_tx_resources(struct ice_pf *pf)
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = ICE_FDIR_NUM_TX_DESC;
 	txq->queue_id = ICE_FDIR_QUEUE_ID;
 	txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
@@ -2194,6 +2197,7 @@ ice_fdir_setup_rx_resources(struct ice_pf *pf)
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	rxq->nb_rx_desc = ICE_FDIR_NUM_RX_DESC;
 	rxq->queue_id = ICE_FDIR_QUEUE_ID;
 	rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
drivers/net/ice/ice_rxtx.h +2 -0
index b10db0874d..903c99a640 100644
@@ -89,6 +89,7 @@ struct ice_rx_queue {
 	ice_rxd_to_pkt_fields_t rxd_to_pkt_fields; /* handle FlexiMD by RXDID */
 	ice_rx_release_mbufs_t rx_rel_mbufs;
 	uint64_t offloads;
+	const struct rte_memzone *mz;
 };
 
 struct ice_tx_entry {
@@ -133,6 +134,7 @@ struct ice_tx_queue {
 	bool tx_deferred_start; /* don't start this queue in dev start */
 	bool q_set; /* indicate if tx queue has been configured */
 	ice_tx_release_mbufs_t tx_rel_mbufs;
+	const struct rte_memzone *mz;
 };
 
 /* Offload features */
Signature · 1 line
2.23.0
Acked-by on v3 2/4
#24 lore raw

Re: [dpdk-dev] [PATCH v3 2/4] net/ice: fix memzone leak when re-configure the RX/TX queues

Quoted 33 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Wednesday, September 22, 2021 21:29
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v3 2/4] net/ice: fix memzone leak when re-configure the RX/TX queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ice_rx_queue_release
rte_eth_dev_close
-->ice_dev_close
---->ice_free_queues
------>ice_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

And when queue number is changed to small size, the BIG memzone queue index will be lost. This will lead to a memory leak. So we should release the memzone when releasing queues.

Fixes 460d1679586e ("drivers/net: delete HW rings while freeing queues")
Quoted 7 lines
---
 drivers/net/ice/ice_fdir_filter.c | 2 --
 drivers/net/ice/ice_rxtx.c        | 8 ++++++--
 drivers/net/ice/ice_rxtx.h        | 2 ++
 3 files changed, 8 insertions(+), 4 deletions(-)
Quoted 2 lines

--
2.23.0

#25 lore raw

PATCH v3 3/4 net/i40e: fix memzone leak when re-configure the RX/TX queues

In reply to Yunjian Wang

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>i40e_dev_rx_queue_release rte_eth_dev_close
-->i40e_dev_close
---->i40e_dev_free_queues ------>i40e_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

And when queue number is changed to small size, the BIG memzone queue index will be lost. This will lead to a memory leak. So we should release the memzone when releasing queues.

Fixes 460d1679586e ("drivers/net: delete HW rings while freeing queues")
---
 drivers/net/i40e/i40e_fdir.c | 3 ---
 drivers/net/i40e/i40e_rxtx.c | 8 ++++++--
 drivers/net/i40e/i40e_rxtx.h | 2 ++
 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/i40e/i40e_fdir.c +0 -3
index af075fda2a..e910346e4d 100644
@@ -284,7 +284,6 @@ i40e_fdir_teardown(struct i40e_pf *pf)
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi;
-	struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id];
 
 	vsi = pf->fdir.fdir_vsi;
 	if (!vsi)
@@ -301,10 +300,8 @@ i40e_fdir_teardown(struct i40e_pf *pf)
 	if (err)
 		PMD_DRV_LOG(DEBUG, "Failed to do FDIR RX switch off");
 
-	rte_eth_dma_zone_free(dev, "fdir_rx_ring", pf->fdir.rxq->queue_id);
 	i40e_dev_rx_queue_release(pf->fdir.rxq);
 	pf->fdir.rxq = NULL;
-	rte_eth_dma_zone_free(dev, "fdir_tx_ring", pf->fdir.txq->queue_id);
 	i40e_dev_tx_queue_release(pf->fdir.txq);
 	pf->fdir.txq = NULL;
 	i40e_vsi_release(vsi);
drivers/net/i40e/i40e_rxtx.c +6 -2
index 8329cbdd4e..b67eb1ee94 100644
@@ -2034,6 +2034,7 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/* Zero all the descriptors in the ring. */
 	memset(rz->addr, 0, ring_size);
 
@@ -2113,6 +2114,7 @@ i40e_dev_rx_queue_release(void *rxq)
 
 	i40e_rx_queue_release_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -2433,6 +2435,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -2506,6 +2509,7 @@ i40e_dev_tx_queue_release(void *txq)
 
 	i40e_tx_queue_release_mbufs(q);
 	rte_free(q->sw_ring);
+	rte_memzone_free(q->mz);
 	rte_free(q);
 }
 
@@ -3058,7 +3062,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
 			continue;
 		i40e_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
@@ -3066,7 +3069,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
 			continue;
 		i40e_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 }
 
@@ -3109,6 +3111,7 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
 		return I40E_ERR_NO_MEMORY;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = I40E_FDIR_NUM_TX_DESC;
 	txq->queue_id = I40E_FDIR_QUEUE_ID;
 	txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
@@ -3167,6 +3170,7 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
 		return I40E_ERR_NO_MEMORY;
 	}
 
+	rxq->mz = rz;
 	rxq->nb_rx_desc = I40E_FDIR_NUM_RX_DESC;
 	rxq->queue_id = I40E_FDIR_QUEUE_ID;
 	rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
drivers/net/i40e/i40e_rxtx.h +2 -0
index 5ccf5773e8..3c1a2fab89 100644
@@ -121,6 +121,7 @@ struct i40e_rx_queue {
 	uint16_t rx_using_sse; /**<flag indicate the usage of vPMD for rx */
 	uint8_t dcb_tc;         /**< Traffic class of rx queue */
 	uint64_t offloads; /**< Rx offload flags of DEV_RX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 struct i40e_tx_entry {
@@ -166,6 +167,7 @@ struct i40e_tx_queue {
 	bool tx_deferred_start; /**< don't start this queue in dev start */
 	uint8_t dcb_tc;         /**< Traffic class of tx queue */
 	uint64_t offloads; /**< Tx offload flags of DEV_RX_OFFLOAD_* */
+	const struct rte_memzone *mz;
 };
 
 /** Offload features */
Signature · 1 line
2.23.0
Acked-by on v3 3/4
#26 lore raw

Re: [dpdk-dev] [PATCH v3 3/4] net/i40e: fix memzone leak when re-configure the RX/TX queues

Quoted 33 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Wednesday, September 22, 2021 21:30
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v3 3/4] net/i40e: fix memzone leak when re-configure the RX/TX queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>i40e_dev_rx_queue_release rte_eth_dev_close
-->i40e_dev_close
---->i40e_dev_free_queues ------>i40e_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

And when queue number is changed to small size, the BIG memzone queue index will be lost. This will lead to a memory leak. So we should release the memzone when releasing queues.

Fixes 460d1679586e ("drivers/net: delete HW rings while freeing queues")
Quoted 7 lines
---
 drivers/net/i40e/i40e_fdir.c | 3 ---
 drivers/net/i40e/i40e_rxtx.c | 8 ++++++--
 drivers/net/i40e/i40e_rxtx.h | 2 ++
 3 files changed, 8 insertions(+), 5 deletions(-)
Quoted 2 lines

--
2.23.0

#27 lore raw

PATCH v3 4/4 net/ixgbe: fix memzone leak when re-configure the RX/TX queues

In reply to Yunjian Wang

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ixgbe_dev_rx_queue_release rte_eth_dev_close
-->ixgbe_dev_close
---->ixgbe_dev_free_queues ------>ixgbe_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

And when queue number is changed to small size, the BIG memzone queue index will be lost. This will lead to a memory leak. So we should release the memzone when releasing queues.

Fixes 460d1679586e ("drivers/net: delete HW rings while freeing queues")
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx.c +4 -2
index bfdfd5e755..1b6e0489f4 100644
@@ -2482,6 +2482,7 @@ ixgbe_tx_queue_release(struct ixgbe_tx_queue *txq)
 	if (txq != NULL && txq->ops != NULL) {
 		txq->ops->release_mbufs(txq);
 		txq->ops->free_swring(txq);
+		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
 }
@@ -2763,6 +2764,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
 	txq->tx_free_thresh = tx_free_thresh;
@@ -2887,6 +2889,7 @@ ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)
 		ixgbe_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
 		rte_free(rxq->sw_sc_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -3162,6 +3165,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/*
 	 * Zero init all the descriptors in the ring.
 	 */
@@ -3433,14 +3437,12 @@ ixgbe_dev_free_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		ixgbe_dev_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "rx_ring", i);
 	}
 	dev->data->nb_rx_queues = 0;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
 		dev->data->tx_queues[i] = NULL;
-		rte_eth_dma_zone_free(dev, "tx_ring", i);
 	}
 	dev->data->nb_tx_queues = 0;
 }
drivers/net/ixgbe/ixgbe_rxtx.h +2 -0
index 476ef62cfd..a1764f2b08 100644
@@ -138,6 +138,7 @@ struct ixgbe_rx_queue {
 	struct rte_mbuf fake_mbuf;
 	/** hold packets to return to application */
 	struct rte_mbuf *rx_stage[RTE_PMD_IXGBE_RX_MAX_BURST*2];
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -236,6 +237,7 @@ struct ixgbe_tx_queue {
 	uint8_t		    using_ipsec;
 	/**< indicates that IPsec TX feature is in use */
 #endif
+	const struct rte_memzone *mz;
 };
 
 struct ixgbe_txq_ops {
Signature · 1 line
2.23.0
Acked-by on v3 4/4
#28 lore raw

Re: [dpdk-dev] [PATCH v3 4/4] net/ixgbe: fix memzone leak when re-configure the RX/TX queues

Quoted 30 lines

-----Original Message-----
From: Yunjian Wang <[email protected]>
Sent: Wednesday, September 22, 2021 21:30
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yunjian Wang <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v3 4/4] net/ixgbe: fix memzone leak when re-configure the RX/TX queues

Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like:

rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free
---->slave_remove
------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>ixgbe_dev_rx_queue_release rte_eth_dev_close
-->ixgbe_dev_close
---->ixgbe_dev_free_queues ------>ixgbe_dev_rx_queue_release
(not been called due to nb_rx_queues and nb_tx_queues are 0)

And when queue number is changed to small size, the BIG memzone queue index will be lost. This will lead to a memory leak. So we should release the memzone when releasing queues.

Quoted 9 lines
Fixes 460d1679586e ("drivers/net: delete HW rings while freeing queues")
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
Quoted 2 lines

--
2.23.0

#29 lore raw

Re: [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers

In reply to Yunjian Wang
Quoted 10 lines · Yunjian Wang

This series for fixing memzone leak when re-configure the RX/TX queues for igb, ixgbe, i40e, ice & em drivers.

---
v3:
* 1. Update commit log
* 2. And ice fdir rxq/txq memzones are freed
v2:
* Update commit log

Quoted 6 lines

Yunjian Wang (4):
net/e1000: fix memzone leak when re-configure the RX/TX queues net/ice: fix memzone leak when re-configure the RX/TX queues net/i40e: fix memzone leak when re-configure the RX/TX queues net/ixgbe: fix memzone leak when re-configure the RX/TX queues

Series applied to dpdk-next-net/main, thanks.