[2/2] mempool/cnxk: fix alloc from non-EAL pthreads
Checks
Commit Message
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(+)
Comments
On Mon, Jul 31, 2023 at 11:25 AM Ashwin Sekhar T K <asekhar@marvell.com> wrote:
>
> 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(+)
>
> diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c
> index 41b755b52b..9594370ecd 100644
> --- a/drivers/mempool/cnxk/cn10k_mempool_ops.c
> +++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c
> @@ -326,6 +326,12 @@ cn10k_mempool_deq(struct rte_mempool *mp, void **obj_table, unsigned int n)
Looks like same problem on enq() as well, if so, please fix the same.
> 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
>
@@ -326,6 +326,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);