mempool/cnxk: limit usage of async allocs
PATCH 1/2 mempool/cnxk: limit usage of async allocs
Currently mempool_cnxk driver uses asynchronous allocation for all pools. This asynchronous allocation can result in local caching of additional 512 objects on a single core even when cache is disabled. This will eventually lead to starvation on pools where the number of objects is very less.
This commit changes this logic to use asynchronous allocation on only those pools which have local cache enabled. Also the async buffer size will be RTE_ALIGN_CEIL(rte_mempool->cache_size, 16). This means that when cache is disabled, async alloc will be completely disabled and when cache is enabled, the additional caching due to asynchronous allocation will be limited.
A limitation has been added to cnxk documentation warning the users to adjust the local cache sizes accordingly.
--- doc/guides/nics/cnxk.rst | 18 ++++ drivers/mempool/cnxk/cn10k_mempool_ops.c | 103 ++++++++++++++++++++--- 2 files changed, 110 insertions(+), 11 deletions(-)
doc/guides/nics/cnxk.rst +18 -0
@@ -433,6 +433,24 @@ The OCTEON CN9K/CN10K SoC family NIC has inbuilt HW assisted external mempool ma as it is performance wise most effective way for packet allocation and Tx buffer recycling on OCTEON 9 SoC platform. +``mempool_cnxk`` rte_mempool cache sizes for CN10K +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The OCTEON CN10K SoC Family supports asynchronous batch allocation of +objects from an NPA pool. In the CNXK mempool driver, asynchronous batch +allocation is enabled when local caches are enabled. This asynchronous +batch allocation will be using an additional local async buffer whose size +will be equal to ``RTE_ALIGN_CEIL(rte_mempool->cache_size, 16)``. This can +result in additional objects being cached locally. While creating an +rte_mempool using ``mempool_cnxk`` driver for OCTEON CN10K, this must be +taken into consideration and the local cache sizes should be adjusted +accordingly so that starvation does not happen. + +For Eg: If the ``cache_size`` passed into ``rte_mempool_create`` is ``8``, +then the max objects than can get cached locally on a core would be the +sum of max objects in the local cache + max objects in the async buffer +i.e ``8 + RTE_ALIGN_CEIL(8, 16) = 24``. + CRC stripping ~~~~~~~~~~~~~
drivers/mempool/cnxk/cn10k_mempool_ops.c +92 -11
191 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/2 mempool/cnxk: fix alloc from non-EAL pthreads
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.
--- drivers/mempool/cnxk/cn10k_mempool_ops.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mempool/cnxk/cn10k_mempool_ops.c +6 -0
@@ -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);
Signature · 1 line
2.25.1
Re: [PATCH 2/2] mempool/cnxk: fix alloc from non-EAL pthreads
drivers/mempool/cnxk/cn10k_mempool_ops.c cn10k_mempool_deq(struct rte_mempool *mp, void **obj_table, unsigned int n)
Quoted 18 lines · Ashwin Sekhar T K
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 <[email protected]>--- drivers/mempool/cnxk/cn10k_mempool_ops.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/mempool/cnxk/cn10k_mempool_ops.c +0
-0@@ -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.
Quoted 15 lines
drivers/mempool/cnxk/cn10k_mempool_ops.c +6
-1struct 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
PATCH 1/3 mempool/cnxk: limit usage of async allocs
In reply to Ashwin Sekhar T KCurrently mempool_cnxk driver uses asynchronous allocation for all pools. This asynchronous allocation can result in local caching of additional 512 objects on a single core even when cache is disabled. This will eventually lead to starvation on pools where the number of objects is very less.
This commit changes this logic to use asynchronous allocation on only those pools which have local cache enabled. Also the async buffer size will be RTE_ALIGN_CEIL(rte_mempool->cache_size, 16). This means that when cache is disabled, async alloc will be completely disabled and when cache is enabled, the additional caching due to asynchronous allocation will be limited.
A limitation has been added to cnxk documentation warning the users to adjust the local cache sizes accordingly.
--- doc/guides/nics/cnxk.rst | 18 ++++ drivers/mempool/cnxk/cn10k_mempool_ops.c | 103 ++++++++++++++++++++--- 2 files changed, 110 insertions(+), 11 deletions(-)
doc/guides/nics/cnxk.rst +18 -0
@@ -433,6 +433,24 @@ The OCTEON CN9K/CN10K SoC family NIC has inbuilt HW assisted external mempool ma as it is performance wise most effective way for packet allocation and Tx buffer recycling on OCTEON 9 SoC platform. +``mempool_cnxk`` rte_mempool cache sizes for CN10K +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The OCTEON CN10K SoC Family supports asynchronous batch allocation of +objects from an NPA pool. In the CNXK mempool driver, asynchronous batch +allocation is enabled when local caches are enabled. This asynchronous +batch allocation will be using an additional local async buffer whose size +will be equal to ``RTE_ALIGN_CEIL(rte_mempool->cache_size, 16)``. This can +result in additional objects being cached locally. While creating an +rte_mempool using ``mempool_cnxk`` driver for OCTEON CN10K, this must be +taken into consideration and the local cache sizes should be adjusted +accordingly so that starvation does not happen. + +For Eg: If the ``cache_size`` passed into ``rte_mempool_create`` is ``8``, +then the max objects than can get cached locally on a core would be the +sum of max objects in the local cache + max objects in the async buffer +i.e ``8 + RTE_ALIGN_CEIL(8, 16) = 24``. + CRC stripping ~~~~~~~~~~~~~
drivers/mempool/cnxk/cn10k_mempool_ops.c +92 -11
191 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/3 mempool/cnxk: fix free from non-EAL pthreads
From: Harman Kalra <[email protected]>
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.
--- drivers/mempool/cnxk/cn10k_mempool_ops.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mempool/cnxk/cn10k_mempool_ops.c +6 -0
@@ -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 ;
Signature · 1 line
2.25.1
PATCH 3/3 mempool/cnxk: fix alloc from non-EAL pthreads
In reply to Ashwin Sekhar T KFor 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.
--- drivers/mempool/cnxk/cn10k_mempool_ops.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mempool/cnxk/cn10k_mempool_ops.c +6 -0
@@ -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);
Signature · 1 line
2.25.1
Quoted 14 lines · Ashwin Sekhar T K
Currently
mempool_cnxkdriver uses asynchronous allocation for all pools. This asynchronous allocation can result in local caching of additional 512 objects on a single core even when cache is disabled. This will eventually lead to starvation on pools where the number of objects is very less.This commit changes this logic to use asynchronous allocation on only those pools which have local cache enabled. Also the async buffer size will be
RTE_ALIGN_CEIL(rte_mempool->cache_size, 16). This means that when cache is disabled, async alloc will be completely disabled and when cache is enabled, the additional caching due to asynchronous allocation will be limited.
Quoted 4 lines
A limitation has been added to cnxk documentation warning the users to adjust the local cache sizes accordingly.
Signed-off-by Ashwin Sekhar T K <[email protected]>
Series applied to dpdk-next-net-mrvl/for-next-net. Thanks