* [PATCH] mempool/cnxk: avoid indefinite wait when counting batch alloc pointers
@ 2023-04-11 7:21 Ashwin Sekhar T K
2023-05-03 12:12 ` Jerin Jacob
0 siblings, 1 reply; 2+ messages in thread
From: Ashwin Sekhar T K @ 2023-04-11 7:21 UTC (permalink / raw)
To: dev, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori,
Satha Rao, Ashwin Sekhar T K, Pavan Nikhilesh
Cc: jerinj, psatheesh, anoobj, gakhil, hkalra
Avoid waiting indefinitely when counting batch alloc pointers by adding a
wait timeout.
Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
---
drivers/common/cnxk/roc_npa.h | 15 +++++++++------
drivers/mempool/cnxk/cn10k_mempool_ops.c | 3 ++-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index dd588b0322..1ef3ecc08a 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -241,19 +241,23 @@ roc_npa_aura_batch_alloc_issue(uint64_t aura_handle, uint64_t *buf,
}
static inline void
-roc_npa_batch_alloc_wait(uint64_t *cache_line)
+roc_npa_batch_alloc_wait(uint64_t *cache_line, unsigned int wait_us)
{
+ const uint64_t ticks = (uint64_t)wait_us * plt_tsc_hz() / (uint64_t)1E6;
+ const uint64_t start = plt_tsc_cycles();
+
/* Batch alloc status code is updated in bits [5:6] of the first word
* of the 128 byte cache line.
*/
while (((__atomic_load_n(cache_line, __ATOMIC_RELAXED) >> 5) & 0x3) ==
ALLOC_CCODE_INVAL)
- ;
+ if (wait_us && (plt_tsc_cycles() - start) >= ticks)
+ break;
}
static inline unsigned int
roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num,
- unsigned int do_wait)
+ unsigned int wait_us)
{
unsigned int count, i;
@@ -267,8 +271,7 @@ roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num,
status = (struct npa_batch_alloc_status_s *)&aligned_buf[i];
- if (do_wait)
- roc_npa_batch_alloc_wait(&aligned_buf[i]);
+ roc_npa_batch_alloc_wait(&aligned_buf[i], wait_us);
count += status->count;
}
@@ -293,7 +296,7 @@ roc_npa_aura_batch_alloc_extract(uint64_t *buf, uint64_t *aligned_buf,
status = (struct npa_batch_alloc_status_s *)&aligned_buf[i];
- roc_npa_batch_alloc_wait(&aligned_buf[i]);
+ roc_npa_batch_alloc_wait(&aligned_buf[i], 0);
line_count = status->count;
diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c
index ba826f0f01..ff0015d8de 100644
--- a/drivers/mempool/cnxk/cn10k_mempool_ops.c
+++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c
@@ -9,6 +9,7 @@
#define BATCH_ALLOC_SZ ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS
#define BATCH_OP_DATA_TABLE_MZ_NAME "batch_op_data_table_mz"
+#define BATCH_ALLOC_WAIT_US 5
enum batch_op_status {
BATCH_ALLOC_OP_NOT_ISSUED = 0,
@@ -178,7 +179,7 @@ cn10k_mempool_get_count(const struct rte_mempool *mp)
if (mem->status == BATCH_ALLOC_OP_ISSUED)
count += roc_npa_aura_batch_alloc_count(
- mem->objs, BATCH_ALLOC_SZ, 1);
+ mem->objs, BATCH_ALLOC_SZ, BATCH_ALLOC_WAIT_US);
if (mem->status == BATCH_ALLOC_OP_DONE)
count += mem->sz;
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mempool/cnxk: avoid indefinite wait when counting batch alloc pointers
2023-04-11 7:21 [PATCH] mempool/cnxk: avoid indefinite wait when counting batch alloc pointers Ashwin Sekhar T K
@ 2023-05-03 12:12 ` Jerin Jacob
0 siblings, 0 replies; 2+ messages in thread
From: Jerin Jacob @ 2023-05-03 12:12 UTC (permalink / raw)
To: Ashwin Sekhar T K
Cc: dev, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori,
Satha Rao, Pavan Nikhilesh, jerinj, psatheesh, anoobj, gakhil,
hkalra
On Tue, Apr 11, 2023 at 12:52 PM Ashwin Sekhar T K <asekhar@marvell.com> wrote:
>
> Avoid waiting indefinitely when counting batch alloc pointers by adding a
> wait timeout.
>
> Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
Updated the git commit as follows and applied to
dpdk-next-net-mrvl/for-next-net. Thanks
mempool/cnxk: avoid hang when counting batch allocs
Avoid waiting indefinitely when counting batch alloc pointers by adding a
wait timeout.
Fixes: 8f2cd7946083 ("mempool/cnxk: add cn10k get count")
Cc: stable@dpdk.org
Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
> ---
> drivers/common/cnxk/roc_npa.h | 15 +++++++++------
> drivers/mempool/cnxk/cn10k_mempool_ops.c | 3 ++-
> 2 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
> index dd588b0322..1ef3ecc08a 100644
> --- a/drivers/common/cnxk/roc_npa.h
> +++ b/drivers/common/cnxk/roc_npa.h
> @@ -241,19 +241,23 @@ roc_npa_aura_batch_alloc_issue(uint64_t aura_handle, uint64_t *buf,
> }
>
> static inline void
> -roc_npa_batch_alloc_wait(uint64_t *cache_line)
> +roc_npa_batch_alloc_wait(uint64_t *cache_line, unsigned int wait_us)
> {
> + const uint64_t ticks = (uint64_t)wait_us * plt_tsc_hz() / (uint64_t)1E6;
> + const uint64_t start = plt_tsc_cycles();
> +
> /* Batch alloc status code is updated in bits [5:6] of the first word
> * of the 128 byte cache line.
> */
> while (((__atomic_load_n(cache_line, __ATOMIC_RELAXED) >> 5) & 0x3) ==
> ALLOC_CCODE_INVAL)
> - ;
> + if (wait_us && (plt_tsc_cycles() - start) >= ticks)
> + break;
> }
>
> static inline unsigned int
> roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num,
> - unsigned int do_wait)
> + unsigned int wait_us)
> {
> unsigned int count, i;
>
> @@ -267,8 +271,7 @@ roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num,
>
> status = (struct npa_batch_alloc_status_s *)&aligned_buf[i];
>
> - if (do_wait)
> - roc_npa_batch_alloc_wait(&aligned_buf[i]);
> + roc_npa_batch_alloc_wait(&aligned_buf[i], wait_us);
>
> count += status->count;
> }
> @@ -293,7 +296,7 @@ roc_npa_aura_batch_alloc_extract(uint64_t *buf, uint64_t *aligned_buf,
>
> status = (struct npa_batch_alloc_status_s *)&aligned_buf[i];
>
> - roc_npa_batch_alloc_wait(&aligned_buf[i]);
> + roc_npa_batch_alloc_wait(&aligned_buf[i], 0);
>
> line_count = status->count;
>
> diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c
> index ba826f0f01..ff0015d8de 100644
> --- a/drivers/mempool/cnxk/cn10k_mempool_ops.c
> +++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c
> @@ -9,6 +9,7 @@
>
> #define BATCH_ALLOC_SZ ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS
> #define BATCH_OP_DATA_TABLE_MZ_NAME "batch_op_data_table_mz"
> +#define BATCH_ALLOC_WAIT_US 5
>
> enum batch_op_status {
> BATCH_ALLOC_OP_NOT_ISSUED = 0,
> @@ -178,7 +179,7 @@ cn10k_mempool_get_count(const struct rte_mempool *mp)
>
> if (mem->status == BATCH_ALLOC_OP_ISSUED)
> count += roc_npa_aura_batch_alloc_count(
> - mem->objs, BATCH_ALLOC_SZ, 1);
> + mem->objs, BATCH_ALLOC_SZ, BATCH_ALLOC_WAIT_US);
>
> if (mem->status == BATCH_ALLOC_OP_DONE)
> count += mem->sz;
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-03 12:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-11 7:21 [PATCH] mempool/cnxk: avoid indefinite wait when counting batch alloc pointers Ashwin Sekhar T K
2023-05-03 12:12 ` Jerin Jacob
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).