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

Message ID 20230822170157.2637286-3-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
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Ashwin Sekhar T K Aug. 22, 2023, 5:01 p.m. UTC
  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@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 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);