DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/4] delete HW rings when releasing queues
@ 2021-09-17 11:24 Yunjian Wang
  2021-09-17 11:24 ` [dpdk-dev] [PATCH 1/4] net/e1000: " Yunjian Wang
                   ` (5 more replies)
  0 siblings, 6 replies; 30+ messages in thread
From: Yunjian Wang @ 2021-09-17 11:24 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	Yunjian Wang

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(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH 1/4] net/e1000: delete HW rings when releasing queues
  2021-09-17 11:24 [dpdk-dev] [PATCH 0/4] delete HW rings when releasing queues Yunjian Wang
@ 2021-09-17 11:24 ` Yunjian Wang
  2021-09-17 11:24 ` [dpdk-dev] [PATCH 2/4] net/ice: " Yunjian Wang
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 30+ messages in thread
From: Yunjian Wang @ 2021-09-17 11:24 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/e1000/em_rxtx.c  | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index dfd8f2fd00..82928083f5 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -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;
 }
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 278d5d2712..dc0de37246 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -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;
 }
-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH 2/4] net/ice: delete HW rings when releasing queues
  2021-09-17 11:24 [dpdk-dev] [PATCH 0/4] delete HW rings when releasing queues Yunjian Wang
  2021-09-17 11:24 ` [dpdk-dev] [PATCH 1/4] net/e1000: " Yunjian Wang
@ 2021-09-17 11:24 ` Yunjian Wang
  2021-09-17 11:24 ` [dpdk-dev] [PATCH 3/4] net/i40e: " Yunjian Wang
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 30+ messages in thread
From: Yunjian Wang @ 2021-09-17 11:24 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/ice/ice_rxtx.c | 6 ++++--
 drivers/net/ice/ice_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 5d7ab4f047..472da6bf83 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -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;
 }
diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h
index b10db0874d..903c99a640 100644
--- a/drivers/net/ice/ice_rxtx.h
+++ b/drivers/net/ice/ice_rxtx.h
@@ -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 */
-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH 3/4] net/i40e: delete HW rings when releasing queues
  2021-09-17 11:24 [dpdk-dev] [PATCH 0/4] delete HW rings when releasing queues Yunjian Wang
  2021-09-17 11:24 ` [dpdk-dev] [PATCH 1/4] net/e1000: " Yunjian Wang
  2021-09-17 11:24 ` [dpdk-dev] [PATCH 2/4] net/ice: " Yunjian Wang
@ 2021-09-17 11:24 ` Yunjian Wang
  2021-09-17 11:25 ` [dpdk-dev] [PATCH 4/4] net/ixgbe: " Yunjian Wang
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 30+ messages in thread
From: Yunjian Wang @ 2021-09-17 11:24 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 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(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index af075fda2a..e910346e4d 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -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);
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 8329cbdd4e..b67eb1ee94 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -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;
diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
index 5ccf5773e8..3c1a2fab89 100644
--- a/drivers/net/i40e/i40e_rxtx.h
+++ b/drivers/net/i40e/i40e_rxtx.h
@@ -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 */
-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-17 11:24 [dpdk-dev] [PATCH 0/4] delete HW rings when releasing queues Yunjian Wang
                   ` (2 preceding siblings ...)
  2021-09-17 11:24 ` [dpdk-dev] [PATCH 3/4] net/i40e: " Yunjian Wang
@ 2021-09-17 11:25 ` Yunjian Wang
  2021-09-17 15:46   ` Wang, Haiyue
  2021-09-18  8:33 ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers Yunjian Wang
  2021-09-22 13:27 ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Yunjian Wang
  5 siblings, 1 reply; 30+ messages in thread
From: Yunjian Wang @ 2021-09-17 11:25 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index bfdfd5e755..1b6e0489f4 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -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;
 }
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index 476ef62cfd..a1764f2b08 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-17 11:25 ` [dpdk-dev] [PATCH 4/4] net/ixgbe: " Yunjian Wang
@ 2021-09-17 15:46   ` Wang, Haiyue
  2021-09-18  3:10     ` wangyunjian
  0 siblings, 1 reply; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-17 15:46 UTC (permalink / raw)
  To: Yunjian Wang, dev; +Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong

> -----Original Message-----
> From: Yunjian Wang <wangyunjian@huawei.com>
> Sent: Friday, September 17, 2021 19:25
> To: dev@dpdk.org
> Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>
> Subject: [dpdk-dev] [PATCH 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
>  - 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 ?

> In order to free the memzone, we can release the memzone
> when releasing queues.
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---


> --
> 2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-17 15:46   ` Wang, Haiyue
@ 2021-09-18  3:10     ` wangyunjian
  2021-09-18  3:19       ` Wang, Haiyue
  0 siblings, 1 reply; 30+ messages in thread
From: wangyunjian @ 2021-09-18  3:10 UTC (permalink / raw)
  To: Wang, Haiyue, dev; +Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong

> -----Original Message-----
> From: Wang, Haiyue [mailto:haiyue.wang@intel.com]
> Sent: Friday, September 17, 2021 11:47 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong
> <dingxiaoxiong@huawei.com>
> Subject: RE: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing
> queues
> 
> > -----Original Message-----
> > From: Yunjian Wang <wangyunjian@huawei.com>
> > Sent: Friday, September 17, 2021 19:25
> > To: dev@dpdk.org
> > Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>; Zhang,
> > Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> > <wangyunjian@huawei.com>
> > Subject: [dpdk-dev] [PATCH 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
> >  - 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 ?

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)

> 
> > In order to free the memzone, we can release the memzone
> > when releasing queues.
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> 
> 
> > --
> > 2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-18  3:10     ` wangyunjian
@ 2021-09-18  3:19       ` Wang, Haiyue
  0 siblings, 0 replies; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-18  3:19 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong

> -----Original Message-----
> From: wangyunjian <wangyunjian@huawei.com>
> Sent: Saturday, September 18, 2021 11:11
> To: Wang, Haiyue <haiyue.wang@intel.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; dingxiaoxiong <dingxiaoxiong@huawei.com>
> Subject: RE: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues
> 
> > -----Original Message-----
> > From: Wang, Haiyue [mailto:haiyue.wang@intel.com]
> > Sent: Friday, September 17, 2021 11:47 PM
> > To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> > Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong
> > <dingxiaoxiong@huawei.com>
> > Subject: RE: [dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing
> > queues
> >
> > > -----Original Message-----
> > > From: Yunjian Wang <wangyunjian@huawei.com>
> > > Sent: Friday, September 17, 2021 19:25
> > > To: dev@dpdk.org
> > > Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei
> > > <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>; Zhang,
> > > Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> > > <wangyunjian@huawei.com>
> > > Subject: [dpdk-dev] [PATCH 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
> > >  - 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 ?
> 
> 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!

> >
> > > In order to free the memzone, we can release the memzone
> > > when releasing queues.
> > >
> > > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > > ---
> >
> >
> > > --
> > > 2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers
  2021-09-17 11:24 [dpdk-dev] [PATCH 0/4] delete HW rings when releasing queues Yunjian Wang
                   ` (3 preceding siblings ...)
  2021-09-17 11:25 ` [dpdk-dev] [PATCH 4/4] net/ixgbe: " Yunjian Wang
@ 2021-09-18  8:33 ` Yunjian Wang
  2021-09-18  8:33   ` [dpdk-dev] [PATCH v2 1/4] net/e1000: delete HW rings when releasing queues Yunjian Wang
                     ` (4 more replies)
  2021-09-22 13:27 ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Yunjian Wang
  5 siblings, 5 replies; 30+ messages in thread
From: Yunjian Wang @ 2021-09-18  8:33 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v2 1/4] net/e1000: delete HW rings when releasing queues
  2021-09-18  8:33 ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers Yunjian Wang
@ 2021-09-18  8:33   ` Yunjian Wang
  2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 2/4] net/ice: " Yunjian Wang
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 30+ messages in thread
From: Yunjian Wang @ 2021-09-18  8:33 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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
------------>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.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/e1000/em_rxtx.c  | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index dfd8f2fd00..82928083f5 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -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;
 }
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 278d5d2712..dc0de37246 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -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;
 }
-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v2 2/4] net/ice: delete HW rings when releasing queues
  2021-09-18  8:33 ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers Yunjian Wang
  2021-09-18  8:33   ` [dpdk-dev] [PATCH v2 1/4] net/e1000: delete HW rings when releasing queues Yunjian Wang
@ 2021-09-18  8:41   ` Yunjian Wang
  2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 3/4] net/i40e: " Yunjian Wang
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 30+ messages in thread
From: Yunjian Wang @ 2021-09-18  8:41 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/ice/ice_rxtx.c | 6 ++++--
 drivers/net/ice/ice_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 5d7ab4f047..472da6bf83 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -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;
 }
diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h
index b10db0874d..903c99a640 100644
--- a/drivers/net/ice/ice_rxtx.h
+++ b/drivers/net/ice/ice_rxtx.h
@@ -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 */
-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v2 3/4] net/i40e: delete HW rings when releasing queues
  2021-09-18  8:33 ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers Yunjian Wang
  2021-09-18  8:33   ` [dpdk-dev] [PATCH v2 1/4] net/e1000: delete HW rings when releasing queues Yunjian Wang
  2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 2/4] net/ice: " Yunjian Wang
@ 2021-09-18  8:41   ` Yunjian Wang
  2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 4/4] net/ixgbe: " Yunjian Wang
  2021-09-20  7:25   ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers David Marchand
  4 siblings, 0 replies; 30+ messages in thread
From: Yunjian Wang @ 2021-09-18  8:41 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 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(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index af075fda2a..e910346e4d 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -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);
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 8329cbdd4e..b67eb1ee94 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -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;
diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
index 5ccf5773e8..3c1a2fab89 100644
--- a/drivers/net/i40e/i40e_rxtx.h
+++ b/drivers/net/i40e/i40e_rxtx.h
@@ -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 */
-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-18  8:33 ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers Yunjian Wang
                     ` (2 preceding siblings ...)
  2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 3/4] net/i40e: " Yunjian Wang
@ 2021-09-18  8:41   ` Yunjian Wang
  2021-09-22  6:22     ` Wang, Haiyue
  2021-09-20  7:25   ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers David Marchand
  4 siblings, 1 reply; 30+ messages in thread
From: Yunjian Wang @ 2021-09-18  8:41 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index bfdfd5e755..1b6e0489f4 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -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;
 }
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index 476ef62cfd..a1764f2b08 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers
  2021-09-18  8:33 ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers Yunjian Wang
                     ` (3 preceding siblings ...)
  2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 4/4] net/ixgbe: " Yunjian Wang
@ 2021-09-20  7:25   ` David Marchand
  2021-09-21  9:21     ` Wang, Haiyue
  4 siblings, 1 reply; 30+ messages in thread
From: David Marchand @ 2021-09-20  7:25 UTC (permalink / raw)
  To: Yunjian Wang, Wang, Haiyue, Yigit, Ferruh
  Cc: dev, Beilei Xing, Qiming Yang, Qi Zhang, dingxiaoxiong, Renata Saiakhova

On Sat, Sep 18, 2021 at 10:34 AM Yunjian Wang <wangyunjian@huawei.com> wrote:
>
> 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(-)
>

- 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?


-- 
David Marchand


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers
  2021-09-20  7:25   ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers David Marchand
@ 2021-09-21  9:21     ` Wang, Haiyue
  0 siblings, 0 replies; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-21  9:21 UTC (permalink / raw)
  To: David Marchand, Yunjian Wang, Yigit, Ferruh
  Cc: dev, Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong,
	Renata Saiakhova

> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Monday, September 20, 2021 15:25
> To: Yunjian Wang <wangyunjian@huawei.com>; Wang, Haiyue <haiyue.wang@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>
> Cc: dev <dev@dpdk.org>; Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>;
> Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Renata Saiakhova
> <Renata.Saiakhova@ekinops.com>
> Subject: Re: [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers
> 
> On Sat, Sep 18, 2021 at 10:34 AM Yunjian Wang <wangyunjian@huawei.com> wrote:
> >
> > 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(-)
> >
> 
> - 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?

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;
	}

> 
> 
> - Is this worth backporting to stable branches?
> 

+1

> 
> --
> David Marchand


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 4/4] net/ixgbe: " Yunjian Wang
@ 2021-09-22  6:22     ` Wang, Haiyue
  2021-09-22  6:58       ` wangyunjian
  0 siblings, 1 reply; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-22  6:22 UTC (permalink / raw)
  To: Yunjian Wang, dev; +Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong

> -----Original Message-----
> From: Yunjian Wang <wangyunjian@huawei.com>
> Sent: Saturday, September 18, 2021 16:42
> To: dev@dpdk.org
> Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>
> 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)
> 
> 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 ?

> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
>  drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
> index bfdfd5e755..1b6e0489f4 100644
> --- a/drivers/net/ixgbe/ixgbe_rxtx.c
> +++ b/drivers/net/ixgbe/ixgbe_rxtx.c
> @@ -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;
>  }
> diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
> index 476ef62cfd..a1764f2b08 100644
> --- a/drivers/net/ixgbe/ixgbe_rxtx.h
> +++ b/drivers/net/ixgbe/ixgbe_rxtx.h
> @@ -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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-22  6:22     ` Wang, Haiyue
@ 2021-09-22  6:58       ` wangyunjian
  2021-09-22  7:04         ` Wang, Haiyue
  0 siblings, 1 reply; 30+ messages in thread
From: wangyunjian @ 2021-09-22  6:58 UTC (permalink / raw)
  To: Wang, Haiyue, dev; +Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong

> -----Original Message-----
> From: Wang, Haiyue [mailto:haiyue.wang@intel.com]
> Sent: Wednesday, September 22, 2021 2:23 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong
> <dingxiaoxiong@huawei.com>
> Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when
> releasing queues
> 
> > -----Original Message-----
> > From: Yunjian Wang <wangyunjian@huawei.com>
> > Sent: Saturday, September 18, 2021 16:42
> > To: dev@dpdk.org
> > Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>; Zhang,
> > Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> > <wangyunjian@huawei.com>
> > 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)
> >
> > 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 ?

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

> 
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> >  drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
> > drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
> >  2 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c
> > b/drivers/net/ixgbe/ixgbe_rxtx.c index bfdfd5e755..1b6e0489f4 100644
> > --- a/drivers/net/ixgbe/ixgbe_rxtx.c
> > +++ b/drivers/net/ixgbe/ixgbe_rxtx.c
> > @@ -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;
> >  }
> > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h
> > b/drivers/net/ixgbe/ixgbe_rxtx.h index 476ef62cfd..a1764f2b08 100644
> > --- a/drivers/net/ixgbe/ixgbe_rxtx.h
> > +++ b/drivers/net/ixgbe/ixgbe_rxtx.h
> > @@ -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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-22  6:58       ` wangyunjian
@ 2021-09-22  7:04         ` Wang, Haiyue
  2021-09-22 11:13           ` wangyunjian
  0 siblings, 1 reply; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-22  7:04 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong

> -----Original Message-----
> From: wangyunjian <wangyunjian@huawei.com>
> Sent: Wednesday, September 22, 2021 14:58
> To: Wang, Haiyue <haiyue.wang@intel.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; dingxiaoxiong <dingxiaoxiong@huawei.com>
> Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues
> 
> > -----Original Message-----
> > From: Wang, Haiyue [mailto:haiyue.wang@intel.com]
> > Sent: Wednesday, September 22, 2021 2:23 PM
> > To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> > Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong
> > <dingxiaoxiong@huawei.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when
> > releasing queues
> >
> > > -----Original Message-----
> > > From: Yunjian Wang <wangyunjian@huawei.com>
> > > Sent: Saturday, September 18, 2021 16:42
> > > To: dev@dpdk.org
> > > Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei
> > > <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>; Zhang,
> > > Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> > > <wangyunjian@huawei.com>
> > > 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)
> > >
> > > 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 ?
> 
> 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

> >
> > > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > > ---
> > >  drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
> > > drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
> > >  2 files changed, 6 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c
> > > b/drivers/net/ixgbe/ixgbe_rxtx.c index bfdfd5e755..1b6e0489f4 100644
> > > --- a/drivers/net/ixgbe/ixgbe_rxtx.c
> > > +++ b/drivers/net/ixgbe/ixgbe_rxtx.c
> > > @@ -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;
> > >  }
> > > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h
> > > b/drivers/net/ixgbe/ixgbe_rxtx.h index 476ef62cfd..a1764f2b08 100644
> > > --- a/drivers/net/ixgbe/ixgbe_rxtx.h
> > > +++ b/drivers/net/ixgbe/ixgbe_rxtx.h
> > > @@ -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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-22  7:04         ` Wang, Haiyue
@ 2021-09-22 11:13           ` wangyunjian
  2021-09-22 11:43             ` Wang, Haiyue
  0 siblings, 1 reply; 30+ messages in thread
From: wangyunjian @ 2021-09-22 11:13 UTC (permalink / raw)
  To: Wang, Haiyue, dev; +Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong



> -----Original Message-----
> From: Wang, Haiyue [mailto:haiyue.wang@intel.com]
> Sent: Wednesday, September 22, 2021 3:05 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong
> <dingxiaoxiong@huawei.com>
> Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when
> releasing queues
> 
> > -----Original Message-----
> > From: wangyunjian <wangyunjian@huawei.com>
> > Sent: Wednesday, September 22, 2021 14:58
> > To: Wang, Haiyue <haiyue.wang@intel.com>; dev@dpdk.org
> > Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> > dingxiaoxiong <dingxiaoxiong@huawei.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when
> > releasing queues
> >
> > > -----Original Message-----
> > > From: Wang, Haiyue [mailto:haiyue.wang@intel.com]
> > > Sent: Wednesday, September 22, 2021 2:23 PM
> > > To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> > > Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> > > <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> > > dingxiaoxiong <dingxiaoxiong@huawei.com>
> > > Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings
> > > when releasing queues
> > >
> > > > -----Original Message-----
> > > > From: Yunjian Wang <wangyunjian@huawei.com>
> > > > Sent: Saturday, September 18, 2021 16:42
> > > > To: dev@dpdk.org
> > > > Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei
> > > > <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>;
> > > > Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com;
> > > > Yunjian Wang <wangyunjian@huawei.com>
> > > > 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)
> > > >
> > > > 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 ?
> >
> > 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

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

> 
> > >
> > > > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > > > ---
> > > >  drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
> > > > drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
> > > >  2 files changed, 6 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c
> > > > b/drivers/net/ixgbe/ixgbe_rxtx.c index bfdfd5e755..1b6e0489f4
> > > > 100644
> > > > --- a/drivers/net/ixgbe/ixgbe_rxtx.c
> > > > +++ b/drivers/net/ixgbe/ixgbe_rxtx.c
> > > > @@ -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;
> > > >  }
> > > > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h
> > > > b/drivers/net/ixgbe/ixgbe_rxtx.h index 476ef62cfd..a1764f2b08
> > > > 100644
> > > > --- a/drivers/net/ixgbe/ixgbe_rxtx.h
> > > > +++ b/drivers/net/ixgbe/ixgbe_rxtx.h
> > > > @@ -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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues
  2021-09-22 11:13           ` wangyunjian
@ 2021-09-22 11:43             ` Wang, Haiyue
  0 siblings, 0 replies; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-22 11:43 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong

> -----Original Message-----
> From: wangyunjian <wangyunjian@huawei.com>
> Sent: Wednesday, September 22, 2021 19:14
> To: Wang, Haiyue <haiyue.wang@intel.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; dingxiaoxiong <dingxiaoxiong@huawei.com>
> Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when releasing queues
> 
> 
> 
> > -----Original Message-----
> > From: Wang, Haiyue [mailto:haiyue.wang@intel.com]
> > Sent: Wednesday, September 22, 2021 3:05 PM
> > To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> > Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong
> > <dingxiaoxiong@huawei.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when
> > releasing queues
> >
> > > -----Original Message-----
> > > From: wangyunjian <wangyunjian@huawei.com>
> > > Sent: Wednesday, September 22, 2021 14:58
> > > To: Wang, Haiyue <haiyue.wang@intel.com>; dev@dpdk.org
> > > Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> > > <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> > > dingxiaoxiong <dingxiaoxiong@huawei.com>
> > > Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings when
> > > releasing queues
> > >
> > > > -----Original Message-----
> > > > From: Wang, Haiyue [mailto:haiyue.wang@intel.com]
> > > > Sent: Wednesday, September 22, 2021 2:23 PM
> > > > To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> > > > Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> > > > <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> > > > dingxiaoxiong <dingxiaoxiong@huawei.com>
> > > > Subject: RE: [dpdk-dev] [PATCH v2 4/4] net/ixgbe: delete HW rings
> > > > when releasing queues
> > > >
> > > > > -----Original Message-----
> > > > > From: Yunjian Wang <wangyunjian@huawei.com>
> > > > > Sent: Saturday, September 18, 2021 16:42
> > > > > To: dev@dpdk.org
> > > > > Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei
> > > > > <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>;
> > > > > Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com;
> > > > > Yunjian Wang <wangyunjian@huawei.com>
> > > > > 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)
> > > > >
> > > > > 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 ?
> > >
> > > 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
> 
> 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
> 

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

> >
> > > >
> > > > > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > > > > ---
> > > > >  drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
> > > > > drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
> > > > >  2 files changed, 6 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c
> > > > > b/drivers/net/ixgbe/ixgbe_rxtx.c index bfdfd5e755..1b6e0489f4
> > > > > 100644
> > > > > --- a/drivers/net/ixgbe/ixgbe_rxtx.c
> > > > > +++ b/drivers/net/ixgbe/ixgbe_rxtx.c
> > > > > @@ -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;
> > > > >  }
> > > > > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h
> > > > > b/drivers/net/ixgbe/ixgbe_rxtx.h index 476ef62cfd..a1764f2b08
> > > > > 100644
> > > > > --- a/drivers/net/ixgbe/ixgbe_rxtx.h
> > > > > +++ b/drivers/net/ixgbe/ixgbe_rxtx.h
> > > > > @@ -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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers
  2021-09-17 11:24 [dpdk-dev] [PATCH 0/4] delete HW rings when releasing queues Yunjian Wang
                   ` (4 preceding siblings ...)
  2021-09-18  8:33 ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers Yunjian Wang
@ 2021-09-22 13:27 ` Yunjian Wang
  2021-09-22 13:28   ` [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues Yunjian Wang
                     ` (4 more replies)
  5 siblings, 5 replies; 30+ messages in thread
From: Yunjian Wang @ 2021-09-22 13:27 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	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(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues
  2021-09-22 13:27 ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Yunjian Wang
@ 2021-09-22 13:28   ` Yunjian Wang
  2021-09-22 13:51     ` Wang, Haiyue
  2021-09-22 13:28   ` [dpdk-dev] [PATCH v3 2/4] net/ice: " Yunjian Wang
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 30+ messages in thread
From: Yunjian Wang @ 2021-09-22 13:28 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	Yunjian Wang, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/e1000/em_rxtx.c  | 8 ++++++--
 drivers/net/e1000/igb_rxtx.c | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index dfd8f2fd00..82928083f5 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -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;
 }
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 278d5d2712..dc0de37246 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -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;
 }
-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v3 2/4] net/ice: fix memzone leak when re-configure the RX/TX queues
  2021-09-22 13:27 ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Yunjian Wang
  2021-09-22 13:28   ` [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues Yunjian Wang
@ 2021-09-22 13:28   ` Yunjian Wang
  2021-09-22 13:51     ` Wang, Haiyue
  2021-09-22 13:29   ` [dpdk-dev] [PATCH v3 3/4] net/i40e: " Yunjian Wang
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 30+ messages in thread
From: Yunjian Wang @ 2021-09-22 13:28 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	Yunjian Wang, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 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(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 7ba65b9b04..82adb1fc8b 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -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);
diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 5d7ab4f047..2fc2883059 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -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;
diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h
index b10db0874d..903c99a640 100644
--- a/drivers/net/ice/ice_rxtx.h
+++ b/drivers/net/ice/ice_rxtx.h
@@ -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 */
-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v3 3/4] net/i40e: fix memzone leak when re-configure the RX/TX queues
  2021-09-22 13:27 ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Yunjian Wang
  2021-09-22 13:28   ` [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues Yunjian Wang
  2021-09-22 13:28   ` [dpdk-dev] [PATCH v3 2/4] net/ice: " Yunjian Wang
@ 2021-09-22 13:29   ` Yunjian Wang
  2021-09-22 13:51     ` Wang, Haiyue
  2021-09-22 13:30   ` [dpdk-dev] [PATCH v3 4/4] net/ixgbe: " Yunjian Wang
  2021-10-07 11:39   ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Ferruh Yigit
  4 siblings, 1 reply; 30+ messages in thread
From: Yunjian Wang @ 2021-09-22 13:29 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	Yunjian Wang, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 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(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index af075fda2a..e910346e4d 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -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);
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 8329cbdd4e..b67eb1ee94 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -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;
diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
index 5ccf5773e8..3c1a2fab89 100644
--- a/drivers/net/i40e/i40e_rxtx.h
+++ b/drivers/net/i40e/i40e_rxtx.h
@@ -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 */
-- 
2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v3 4/4] net/ixgbe: fix memzone leak when re-configure the RX/TX queues
  2021-09-22 13:27 ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Yunjian Wang
                     ` (2 preceding siblings ...)
  2021-09-22 13:29   ` [dpdk-dev] [PATCH v3 3/4] net/i40e: " Yunjian Wang
@ 2021-09-22 13:30   ` Yunjian Wang
  2021-09-22 13:51     ` Wang, Haiyue
  2021-10-07 11:39   ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Ferruh Yigit
  4 siblings, 1 reply; 30+ messages in thread
From: Yunjian Wang @ 2021-09-22 13:30 UTC (permalink / raw)
  To: dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong,
	Yunjian Wang, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index bfdfd5e755..1b6e0489f4 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -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;
 }
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index 476ef62cfd..a1764f2b08 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues
  2021-09-22 13:28   ` [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues Yunjian Wang
@ 2021-09-22 13:51     ` Wang, Haiyue
  0 siblings, 0 replies; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-22 13:51 UTC (permalink / raw)
  To: Yunjian Wang, dev
  Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong, stable

> -----Original Message-----
> From: Yunjian Wang <wangyunjian@huawei.com>
> Sent: Wednesday, September 22, 2021 21:28
> To: dev@dpdk.org
> Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>; stable@dpdk.org
> 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.
> 
> Fixes: 460d1679586e ("drivers/net: delete HW rings while freeing queues")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  drivers/net/e1000/em_rxtx.c  | 8 ++++++--
>  drivers/net/e1000/igb_rxtx.c | 9 +++++++--
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/4] net/ice: fix memzone leak when re-configure the RX/TX queues
  2021-09-22 13:28   ` [dpdk-dev] [PATCH v3 2/4] net/ice: " Yunjian Wang
@ 2021-09-22 13:51     ` Wang, Haiyue
  0 siblings, 0 replies; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-22 13:51 UTC (permalink / raw)
  To: Yunjian Wang, dev
  Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong, stable

> -----Original Message-----
> From: Yunjian Wang <wangyunjian@huawei.com>
> Sent: Wednesday, September 22, 2021 21:29
> To: dev@dpdk.org
> Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>; stable@dpdk.org
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  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(-)
> 

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/4] net/i40e: fix memzone leak when re-configure the RX/TX queues
  2021-09-22 13:29   ` [dpdk-dev] [PATCH v3 3/4] net/i40e: " Yunjian Wang
@ 2021-09-22 13:51     ` Wang, Haiyue
  0 siblings, 0 replies; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-22 13:51 UTC (permalink / raw)
  To: Yunjian Wang, dev
  Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong, stable

> -----Original Message-----
> From: Yunjian Wang <wangyunjian@huawei.com>
> Sent: Wednesday, September 22, 2021 21:30
> To: dev@dpdk.org
> Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>; stable@dpdk.org
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  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(-)
> 

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/4] net/ixgbe: fix memzone leak when re-configure the RX/TX queues
  2021-09-22 13:30   ` [dpdk-dev] [PATCH v3 4/4] net/ixgbe: " Yunjian Wang
@ 2021-09-22 13:51     ` Wang, Haiyue
  0 siblings, 0 replies; 30+ messages in thread
From: Wang, Haiyue @ 2021-09-22 13:51 UTC (permalink / raw)
  To: Yunjian Wang, dev
  Cc: Xing, Beilei, Yang, Qiming, Zhang, Qi Z, dingxiaoxiong, stable

> -----Original Message-----
> From: Yunjian Wang <wangyunjian@huawei.com>
> Sent: Wednesday, September 22, 2021 21:30
> To: dev@dpdk.org
> Cc: Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; dingxiaoxiong@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>; stable@dpdk.org
> 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.
> 
> Fixes: 460d1679586e ("drivers/net: delete HW rings while freeing queues")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++--
>  drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 2.23.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers
  2021-09-22 13:27 ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Yunjian Wang
                     ` (3 preceding siblings ...)
  2021-09-22 13:30   ` [dpdk-dev] [PATCH v3 4/4] net/ixgbe: " Yunjian Wang
@ 2021-10-07 11:39   ` Ferruh Yigit
  4 siblings, 0 replies; 30+ messages in thread
From: Ferruh Yigit @ 2021-10-07 11:39 UTC (permalink / raw)
  To: Yunjian Wang, dev
  Cc: haiyue.wang, beilei.xing, qiming.yang, qi.z.zhang, dingxiaoxiong

On 9/22/2021 2:27 PM, Yunjian Wang wrote:
> 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
> 

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2021-10-07 11:40 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17 11:24 [dpdk-dev] [PATCH 0/4] delete HW rings when releasing queues Yunjian Wang
2021-09-17 11:24 ` [dpdk-dev] [PATCH 1/4] net/e1000: " Yunjian Wang
2021-09-17 11:24 ` [dpdk-dev] [PATCH 2/4] net/ice: " Yunjian Wang
2021-09-17 11:24 ` [dpdk-dev] [PATCH 3/4] net/i40e: " Yunjian Wang
2021-09-17 11:25 ` [dpdk-dev] [PATCH 4/4] net/ixgbe: " Yunjian Wang
2021-09-17 15:46   ` Wang, Haiyue
2021-09-18  3:10     ` wangyunjian
2021-09-18  3:19       ` Wang, Haiyue
2021-09-18  8:33 ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers Yunjian Wang
2021-09-18  8:33   ` [dpdk-dev] [PATCH v2 1/4] net/e1000: delete HW rings when releasing queues Yunjian Wang
2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 2/4] net/ice: " Yunjian Wang
2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 3/4] net/i40e: " Yunjian Wang
2021-09-18  8:41   ` [dpdk-dev] [PATCH v2 4/4] net/ixgbe: " Yunjian Wang
2021-09-22  6:22     ` Wang, Haiyue
2021-09-22  6:58       ` wangyunjian
2021-09-22  7:04         ` Wang, Haiyue
2021-09-22 11:13           ` wangyunjian
2021-09-22 11:43             ` Wang, Haiyue
2021-09-20  7:25   ` [dpdk-dev] [PATCH v2 0/4] delete HW rings when releasing queues for some drivers David Marchand
2021-09-21  9:21     ` Wang, Haiyue
2021-09-22 13:27 ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Yunjian Wang
2021-09-22 13:28   ` [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues Yunjian Wang
2021-09-22 13:51     ` Wang, Haiyue
2021-09-22 13:28   ` [dpdk-dev] [PATCH v3 2/4] net/ice: " Yunjian Wang
2021-09-22 13:51     ` Wang, Haiyue
2021-09-22 13:29   ` [dpdk-dev] [PATCH v3 3/4] net/i40e: " Yunjian Wang
2021-09-22 13:51     ` Wang, Haiyue
2021-09-22 13:30   ` [dpdk-dev] [PATCH v3 4/4] net/ixgbe: " Yunjian Wang
2021-09-22 13:51     ` Wang, Haiyue
2021-10-07 11:39   ` [dpdk-dev] [PATCH v3 0/4] fixes for intel drivers Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).