patch 'fbarray: fix incorrect lookbehind behavior' has been queued to stable release 23.11.2
Xueming Li
xuemingl at nvidia.com
Mon Aug 12 14:48:32 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=24869bf93c44350879079bbd8c41d3d6b7bf5acc
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From 24869bf93c44350879079bbd8c41d3d6b7bf5acc Mon Sep 17 00:00:00 2001
From: Anatoly Burakov <anatoly.burakov at intel.com>
Date: Mon, 8 Jul 2024 17:07:33 +0100
Subject: [PATCH] fbarray: fix incorrect lookbehind behavior
Cc: Xueming Li <xuemingl at nvidia.com>
[ upstream commit 8e3712928716a1deb8857c971865aa15dc436b04 ]
Currently, whenever first bit of current index mask is set
(meaning, there is potentially a run starting at the start of the mask),
lookbehind loop is entered.
In that loop, if the last bit of lookbehind mask is not set,
the lookbehind is stopped, and the current lookbehind mask index
is assigned to current index mask.
However, because at that point we are inside a while-loop that
decrements current index mask after each iteration,
this results in erroneous mask index decrement.
Fix lookbehind to avoid erroneous decrement, and add corresponding
unit test.
Fixes: e1ca5dc86226 ("fbarray: add reverse finding of chunk")
Signed-off-by: Vipin Padmam Ramesh <vipinp at vmware.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
app/test/test_fbarray.c | 24 ++++++++++++++++++++++++
lib/eal/common/eal_common_fbarray.c | 3 ++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/app/test/test_fbarray.c b/app/test/test_fbarray.c
index bf89b99e5b..147d6e2a07 100644
--- a/app/test/test_fbarray.c
+++ b/app/test/test_fbarray.c
@@ -111,6 +111,14 @@ static int lookahead_test_setup(void)
return init_array();
}
+static int lookbehind_test_setup(void)
+{
+ /* set index 63 as used */
+ param.start = 63;
+ param.end = 63;
+ return init_array();
+}
+
static int test_invalid(void)
{
struct rte_fbarray dummy;
@@ -732,6 +740,21 @@ static int test_lookahead(void)
return TEST_SUCCESS;
}
+static int test_lookbehind(void)
+{
+ int ret, free_len = 2;
+
+ /* run regular test first */
+ ret = test_find();
+ if (ret != TEST_SUCCESS)
+ return ret;
+
+ /* test if we can find free chunk while crossing mask boundary */
+ TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(¶m.arr, param.start + 1, free_len),
+ param.start - free_len, "Free chunk index is wrong\n");
+ return TEST_SUCCESS;
+}
+
static struct unit_test_suite fbarray_test_suite = {
.suite_name = "fbarray autotest",
.setup = autotest_setup,
@@ -746,6 +769,7 @@ static struct unit_test_suite fbarray_test_suite = {
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_CASE_ST(lookbehind_test_setup, reset_array, test_lookbehind),
TEST_CASES_END()
}
};
diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c
index 8a3e6fd290..6d9b95006c 100644
--- a/lib/eal/common/eal_common_fbarray.c
+++ b/lib/eal/common/eal_common_fbarray.c
@@ -512,7 +512,8 @@ find_prev_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
* as well, so skip that on next iteration.
*/
ignore_msk = UINT64_MAX << need;
- msk_idx = lookbehind_idx;
+ /* outer loop will decrement msk_idx so add 1 */
+ msk_idx = lookbehind_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.655940709 +0800
+++ 0035-fbarray-fix-incorrect-lookbehind-behavior.patch 2024-08-12 20:44:02.005069277 +0800
@@ -1 +1 @@
-From 8e3712928716a1deb8857c971865aa15dc436b04 Mon Sep 17 00:00:00 2001
+From 24869bf93c44350879079bbd8c41d3d6b7bf5acc Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 8e3712928716a1deb8857c971865aa15dc436b04 ]
@@ -20 +22,0 @@
-Cc: stable at dpdk.org
@@ -79 +81 @@
-index 2680b34823..b4f0b0b0c3 100644
+index 8a3e6fd290..6d9b95006c 100644
More information about the stable
mailing list