patch 'fbarray: fix incorrect lookahead behavior' has been queued to stable release 23.11.2

Xueming Li xuemingl at nvidia.com
Mon Aug 12 14:48:31 CEST 2024


Hi,

FYI, your patch has been queued to stable release 23.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 08/14/24. 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=23.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=5e665905758fffbfc8ca37bd8a7eba7cfa7867a8

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 5e665905758fffbfc8ca37bd8a7eba7cfa7867a8 Mon Sep 17 00:00:00 2001
From: Anatoly Burakov <anatoly.burakov at intel.com>
Date: Mon, 8 Jul 2024 17:07:32 +0100
Subject: [PATCH] fbarray: fix incorrect lookahead behavior
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 8c03a149ce957b10d7792a2a78339496dd156e9f ]

Currently, whenever last bit of current index mask is set
(meaning, there is potentially a run starting at the end of the mask),
lookahead loop is entered.
In that loop, if the first bit of lookahead mask is not set,
the lookahead is stopped, and the current lookahead mask index is
assigned to current index mask.
However, because at that point we are inside a for-loop that increments
current index mask after each iteration, this results in erroneous mask
index increment.

Fix lookahead to avoid erroneous increment,
and add corresponding unit test.

Fixes: c44d09811b40 ("eal: add shared indexed file-backed array")

Signed-off-by: Vipin Padmam Ramesh <vipinp at vmware.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
 .mailmap                            |  1 +
 app/test/test_fbarray.c             | 23 +++++++++++++++++++++++
 lib/eal/common/eal_common_fbarray.c |  3 ++-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/.mailmap b/.mailmap
index 8e5ee34a2f..12ed3d1e74 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1510,6 +1510,7 @@ Vincent Jardin <vincent.jardin at 6wind.com>
 Vincent Li <vincent.mc.li at gmail.com>
 Vincent S. Cojot <vcojot at redhat.com>
 Vinh Tran <vinh.t.tran10 at gmail.com>
+Vipin Padmam Ramesh <vipinp at vmware.com>
 Vipin Varghese <vipin.varghese at amd.com> <vipin.varghese at intel.com>
 Vipul Ashri <vipul.ashri at oracle.com>
 Visa Hankala <visa at hankala.org>
diff --git a/app/test/test_fbarray.c b/app/test/test_fbarray.c
index 26a51e2a3e..bf89b99e5b 100644
--- a/app/test/test_fbarray.c
+++ b/app/test/test_fbarray.c
@@ -103,6 +103,14 @@ static int empty_msk_test_setup(void)
 	return 0;
 }
 
+static int lookahead_test_setup(void)
+{
+	/* set index 64 as used */
+	param.start = 64;
+	param.end = 64;
+	return init_array();
+}
+
 static int test_invalid(void)
 {
 	struct rte_fbarray dummy;
@@ -709,6 +717,20 @@ static int test_empty(void)
 	return TEST_SUCCESS;
 }
 
+static int test_lookahead(void)
+{
+	int ret;
+
+	/* run regular test first */
+	ret = test_find();
+	if (ret != TEST_SUCCESS)
+		return ret;
+
+	/* test if we can find free chunk while not starting with 0 */
+	TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(&param.arr, 1, param.start),
+			param.start + 1, "Free chunk index is wrong\n");
+	return TEST_SUCCESS;
+}
 
 static struct unit_test_suite fbarray_test_suite = {
 	.suite_name = "fbarray autotest",
@@ -723,6 +745,7 @@ static struct unit_test_suite fbarray_test_suite = {
 		TEST_CASE_ST(last_msk_test_setup, reset_array, test_find),
 		TEST_CASE_ST(full_msk_test_setup, reset_array, test_find),
 		TEST_CASE_ST(empty_msk_test_setup, reset_array, test_empty),
+		TEST_CASE_ST(lookahead_test_setup, reset_array, test_lookahead),
 		TEST_CASES_END()
 	}
 };
diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c
index 2055bfa57d..8a3e6fd290 100644
--- a/lib/eal/common/eal_common_fbarray.c
+++ b/lib/eal/common/eal_common_fbarray.c
@@ -236,7 +236,8 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
 				 * as well, so skip that on next iteration.
 				 */
 				ignore_msk = ~((1ULL << need) - 1);
-				msk_idx = lookahead_idx;
+				/* outer loop will increment msk_idx so add 1 */
+				msk_idx = lookahead_idx - 1;
 				break;
 			}
 
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-08-12 20:44:03.625983911 +0800
+++ 0034-fbarray-fix-incorrect-lookahead-behavior.patch	2024-08-12 20:44:02.005069277 +0800
@@ -1 +1 @@
-From 8c03a149ce957b10d7792a2a78339496dd156e9f Mon Sep 17 00:00:00 2001
+From 5e665905758fffbfc8ca37bd8a7eba7cfa7867a8 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 8c03a149ce957b10d7792a2a78339496dd156e9f ]
@@ -20 +22,0 @@
-Cc: stable at dpdk.org
@@ -31 +33 @@
-index 74739ec9be..085e5f0004 100644
+index 8e5ee34a2f..12ed3d1e74 100644
@@ -34 +36 @@
-@@ -1534,6 +1534,7 @@ Vincent Jardin <vincent.jardin at 6wind.com>
+@@ -1510,6 +1510,7 @@ Vincent Jardin <vincent.jardin at 6wind.com>
@@ -91 +93 @@
-index 0fe5bcfe06..2680b34823 100644
+index 2055bfa57d..8a3e6fd290 100644


More information about the stable mailing list