From: Yunjian Wang <wangyunjian@huawei.com>
To: <dev@dpdk.org>
Cc: <haiyue.wang@intel.com>, <beilei.xing@intel.com>,
<qiming.yang@intel.com>, <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
Date: Wed, 22 Sep 2021 21:28:20 +0800 [thread overview]
Message-ID: <abf062dd370f31df38d196a4f5ddc60c8ff50601.1632315160.git.wangyunjian@huawei.com> (raw)
In-Reply-To: <cover.1632315160.git.wangyunjian@huawei.com>
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
next prev parent reply other threads:[~2021-09-22 13:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Yunjian Wang [this message]
2021-09-22 13:51 ` [dpdk-dev] [PATCH v3 1/4] net/e1000: fix memzone leak when re-configure the RX/TX queues 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=abf062dd370f31df38d196a4f5ddc60c8ff50601.1632315160.git.wangyunjian@huawei.com \
--to=wangyunjian@huawei.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=dingxiaoxiong@huawei.com \
--cc=haiyue.wang@intel.com \
--cc=qi.z.zhang@intel.com \
--cc=qiming.yang@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).