Skip to contentSkip to conversation

mempool/cnxk: destroy NPA pool only if its created

PATCH Superseded Ashwin Sekhar T K 2 participants 4 messages Nov 8, 2022 – Nov 15, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mempool/cnxk: destroy NPA pool only if its created

In scenarios where rte_mempool_free() is called immediately after rte_mempool_create_empty(), the NPA pool will not be created. In such cases the free path should not call roc_npa_pool_destroy().

---
 drivers/mempool/cnxk/cnxk_mempool_ops.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mempool/cnxk/cnxk_mempool_ops.c +8 -0
index a0b94bb95c..e3026136cf 100644
@@ -126,6 +126,14 @@ cnxk_mempool_free(struct rte_mempool *mp)
 	int rc = 0;
 
 	plt_npa_dbg("aura_handle=0x%" PRIx64, mp->pool_id);
+
+	/* It can happen that rte_mempool_free() is called immediately after
+	 * rte_mempool_create_empty(). In such cases the NPA pool will not be
+	 * allocated.
+	 */
+	if (roc_npa_aura_handle_to_base(mp->pool_id) == NULL)
+		return;
+
 	rc = roc_npa_pool_destroy(mp->pool_id);
 	if (rc)
 		plt_err("Failed to free pool or aura rc=%d", rc);
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 mempool/cnxk: destroy NPA pool only if its created

In scenarios where rte_mempool_free() is called immediately after rte_mempool_create_empty(), the NPA pool will not be created. In such cases the free path should not call roc_npa_pool_destroy().

---
 drivers/mempool/cnxk/cnxk_mempool_ops.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mempool/cnxk/cnxk_mempool_ops.c +8 -0
index a0b94bb95c..3769afd3d1 100644
@@ -126,6 +126,14 @@ cnxk_mempool_free(struct rte_mempool *mp)
 	int rc = 0;
 
 	plt_npa_dbg("aura_handle=0x%" PRIx64, mp->pool_id);
+
+	/* It can happen that rte_mempool_free() is called immediately after
+	 * rte_mempool_create_empty(). In such cases the NPA pool will not be
+	 * allocated.
+	 */
+	if (roc_npa_aura_handle_to_base(mp->pool_id) == 0)
+		return;
+
 	rc = roc_npa_pool_destroy(mp->pool_id);
 	if (rc)
 		plt_err("Failed to free pool or aura rc=%d", rc);
Signature · 1 line
2.25.1
#2 lore raw

PATCH v3 1/1 mempool/cnxk: fix mempool destroy for empty pools

In reply to Ashwin Sekhar T K

In scenarios where rte_mempool_free() is called immediately after rte_mempool_create_empty(), the NPA pool will not be created. In such cases the free path should not call roc_npa_pool_destroy().

Fixes bbf19e89b87c ("mempool/cnxk: add generic operations")
---
 drivers/mempool/cnxk/cnxk_mempool_ops.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mempool/cnxk/cnxk_mempool_ops.c +8 -0
index a0b94bb95c..3769afd3d1 100644
@@ -126,6 +126,14 @@ cnxk_mempool_free(struct rte_mempool *mp)
 	int rc = 0;
 
 	plt_npa_dbg("aura_handle=0x%" PRIx64, mp->pool_id);
+
+	/* It can happen that rte_mempool_free() is called immediately after
+	 * rte_mempool_create_empty(). In such cases the NPA pool will not be
+	 * allocated.
+	 */
+	if (roc_npa_aura_handle_to_base(mp->pool_id) == 0)
+		return;
+
 	rc = roc_npa_pool_destroy(mp->pool_id);
 	if (rc)
 		plt_err("Failed to free pool or aura rc=%d", rc);
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH v3] mempool/cnxk: fix mempool destroy for empty pools

08/11/2022 07:55, Ashwin Sekhar T K:

Quoted 8 lines

In scenarios where rte_mempool_free() is called immediately after rte_mempool_create_empty(), the NPA pool will not be created. In such cases the free path should not call roc_npa_pool_destroy().

Fixes bbf19e89b87c ("mempool/cnxk: add generic operations")

+ Cc: [email protected]

Applied with the title "fix destroying empty pool".