[2/3] mempool/cnxk: fix free from non-EAL pthreads

Message ID 20230822170157.2637286-2-asekhar@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [1/3] mempool/cnxk: limit usage of async allocs |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ashwin Sekhar T K Aug. 22, 2023, 5:01 p.m. UTC
  From: Harman Kalra <hkalra@marvell.com>

For non-EAL pthreads, rte_lcore_id() will not be valid.
So, batch free cannot be used as those threads won't have
dedicated lmtlines. So, fallback to bulk alloc in such cases.

Fixes: ecbc731a2286 ("mempool/cnxk: add cn10k batch enqueue")

Signed-off-by: Harman Kalra <hkalra@marvell.com>
Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
---
 drivers/mempool/cnxk/cn10k_mempool_ops.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c
index 41b755b52b..2e46204c8d 100644
--- a/drivers/mempool/cnxk/cn10k_mempool_ops.c
+++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c
@@ -162,6 +162,12 @@  cn10k_mempool_enq(struct rte_mempool *mp, void *const *obj_table,
 	 */
 	rte_io_wmb();
 
+	/* For non-EAL threads, rte_lcore_id() will not be valid. Hence
+	 * fallback to bulk alloc
+	 */
+	if (unlikely(rte_lcore_id() == LCORE_ID_ANY))
+		return cnxk_mempool_enq(mp, obj_table, n);
+
 	if (n == 1) {
 		roc_npa_aura_op_free(mp->pool_id, 1, ptr[0]);
 		return 0;