[PATCH 3/3] mempool/cnxk: fix alloc from non-EAL pthreads
Ashwin Sekhar T K
asekhar at marvell.com
Tue Aug 22 19:01:57 CEST 2023
For non-EAL pthreads, rte_lcore_id() will not be valid.
So, batch allocation cannot be used as we won't have a
dedicated alloc buffer for the thread. So, fallback to
bulk alloc in such cases.
Fixes: 91531e63f43b ("mempool/cnxk: add cn10k batch dequeue")
Signed-off-by: Ashwin Sekhar T K <asekhar at marvell.com>
---
drivers/mempool/cnxk/cn10k_mempool_ops.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c
index 2e46204c8d..2a5aad0008 100644
--- a/drivers/mempool/cnxk/cn10k_mempool_ops.c
+++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c
@@ -332,6 +332,12 @@ cn10k_mempool_deq(struct rte_mempool *mp, void **obj_table, unsigned int n)
struct batch_op_data *op_data;
unsigned int count = 0;
+ /* 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_deq(mp, obj_table, n);
+
op_data = batch_op_data_get(mp->pool_id);
if (op_data->max_async_batch)
count = mempool_deq_batch_async(mp, obj_table, n);
--
2.25.1
More information about the dev
mailing list