patch 'mempool/cnxk: avoid hang when counting batch allocs' has been queued to stable release 22.11.3

Xueming Li xuemingl at nvidia.com
Sun Jun 25 08:35:11 CEST 2023


Hi,

FYI, your patch has been queued to stable release 22.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/27/23. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=9d1dbc6a017eb7cb18f83c0e6b1f24cbc8a1afbf

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 9d1dbc6a017eb7cb18f83c0e6b1f24cbc8a1afbf Mon Sep 17 00:00:00 2001
From: Ashwin Sekhar T K <asekhar at marvell.com>
Date: Tue, 11 Apr 2023 12:51:46 +0530
Subject: [PATCH] mempool/cnxk: avoid hang when counting batch allocs
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 6df1bc6b3b7e1b5d81dc26720a0f0593ed94995a ]

Avoid waiting indefinitely when counting batch alloc pointers by adding a
wait timeout.

Fixes: 8f2cd7946083 ("mempool/cnxk: add cn10k get count")

Signed-off-by: Ashwin Sekhar T K <asekhar at 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 fed1942404..46b668a310 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -253,19 +253,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;
 
@@ -279,8 +283,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;
 	}
@@ -305,7 +308,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

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-06-25 14:32:01.025262900 +0800
+++ 0093-mempool-cnxk-avoid-hang-when-counting-batch-allocs.patch	2023-06-25 14:31:58.535773900 +0800
@@ -1 +1 @@
-From 6df1bc6b3b7e1b5d81dc26720a0f0593ed94995a Mon Sep 17 00:00:00 2001
+From 9d1dbc6a017eb7cb18f83c0e6b1f24cbc8a1afbf Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 6df1bc6b3b7e1b5d81dc26720a0f0593ed94995a ]
@@ -10 +12,0 @@
-Cc: stable at dpdk.org
@@ -19 +21 @@
-index dd588b0322..1ef3ecc08a 100644
+index fed1942404..46b668a310 100644
@@ -22 +24 @@
-@@ -241,19 +241,23 @@ roc_npa_aura_batch_alloc_issue(uint64_t aura_handle, uint64_t *buf,
+@@ -253,19 +253,23 @@ roc_npa_aura_batch_alloc_issue(uint64_t aura_handle, uint64_t *buf,
@@ -49 +51 @@
-@@ -267,8 +271,7 @@ roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num,
+@@ -279,8 +283,7 @@ roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num,
@@ -59 +61 @@
-@@ -293,7 +296,7 @@ roc_npa_aura_batch_alloc_extract(uint64_t *buf, uint64_t *aligned_buf,
+@@ -305,7 +308,7 @@ roc_npa_aura_batch_alloc_extract(uint64_t *buf, uint64_t *aligned_buf,


More information about the stable mailing list