patch 'fbarray: fix lookahead ignore mask handling' has been queued to stable release 21.11.8
Kevin Traynor
ktraynor at redhat.com
Fri Aug 23 18:18:20 CEST 2024
Hi,
FYI, your patch has been queued to stable release 21.11.8
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/28/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://github.com/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/0f46faa56ff6ccd95acd4ac2677370bee2e92200
Thanks.
Kevin
---
>From 0f46faa56ff6ccd95acd4ac2677370bee2e92200 Mon Sep 17 00:00:00 2001
From: Anatoly Burakov <anatoly.burakov at intel.com>
Date: Mon, 8 Jul 2024 17:07:34 +0100
Subject: [PATCH] fbarray: fix lookahead ignore mask handling
[ upstream commit a344719c181aac28cb2ada0d2ddbfee8ad737a1a ]
When lookahead mask does not have its first bit set,
we can infer that we've lost our run.
However, currently, we set ignore mask to ignore `need` number of bits,
which is incorrect because while there is no *current* run
within those bits, we might still be able to start a new run
within those ignored bits later.
This issue is fixed by counting how many shifts it took to lose the run,
and this is the number of bits we should ignore
(+1 to skip one we stopped on).
Also, add unit tests to reproduce the problem.
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>
---
app/test/test_fbarray.c | 28 ++++++++++++++++++++++++++++
lib/eal/common/eal_common_fbarray.c | 13 ++++++++++---
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/app/test/test_fbarray.c b/app/test/test_fbarray.c
index f448d4f196..38a62cd456 100644
--- a/app/test/test_fbarray.c
+++ b/app/test/test_fbarray.c
@@ -756,4 +756,30 @@ static int test_lookbehind(void)
}
+static int test_lookahead_mask(void)
+{
+ /*
+ * There is a certain type of lookahead behavior we want to test here,
+ * namely masking of bits that were scanned with lookahead but that we
+ * know do not match our criteria. This is achieved in following steps:
+ *
+ * 0. Look for a big enough chunk of free space (say, 62 elements)
+ * 1. Trigger lookahead by breaking a run somewhere inside mask 0
+ * (indices 0-63)
+ * 2. Fail lookahead by breaking the run somewhere inside mask 1
+ * (indices 64-127)
+ * 3. Ensure that we can still find free space in mask 1 afterwards
+ */
+
+ /* break run on first mask */
+ rte_fbarray_set_used(¶m.arr, 61);
+ /* break run on second mask */
+ rte_fbarray_set_used(¶m.arr, 70);
+
+ /* we expect to find free space at 71 */
+ TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(¶m.arr, 0, 62),
+ 71, "Free chunk index is wrong\n");
+ return TEST_SUCCESS;
+}
+
static struct unit_test_suite fbarray_test_suite = {
.suite_name = "fbarray autotest",
@@ -771,4 +797,6 @@ static struct unit_test_suite fbarray_test_suite = {
TEST_CASE_ST(lookahead_test_setup, reset_array, test_lookahead),
TEST_CASE_ST(lookbehind_test_setup, reset_array, test_lookbehind),
+ /* setup for these tests is more complex so do it in test func */
+ TEST_CASE_ST(NULL, reset_array, test_lookahead_mask),
TEST_CASES_END()
}
diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c
index 0013ef2c55..def47ceef0 100644
--- a/lib/eal/common/eal_common_fbarray.c
+++ b/lib/eal/common/eal_common_fbarray.c
@@ -220,4 +220,6 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
lookahead_idx++) {
unsigned int s_idx, need;
+ uint64_t first_bit = 1;
+
lookahead_msk = msk->data[lookahead_idx];
@@ -229,9 +231,14 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
need = RTE_MIN(left, MASK_ALIGN);
- for (s_idx = 0; s_idx < need - 1; s_idx++)
+ /* count number of shifts we performed */
+ for (s_idx = 0; s_idx < need - 1; s_idx++) {
lookahead_msk &= lookahead_msk >> 1ULL;
+ /* did we lose the run yet? */
+ if ((lookahead_msk & first_bit) == 0)
+ break;
+ }
/* if first bit is not set, we've lost the run */
- if ((lookahead_msk & 1) == 0) {
+ if ((lookahead_msk & first_bit) == 0) {
/*
* we've scanned this far, so we know there are
@@ -239,5 +246,5 @@ 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);
+ ignore_msk = ~((1ULL << (s_idx + 1)) - 1);
/* outer loop will increment msk_idx so add 1 */
msk_idx = lookahead_idx - 1;
--
2.46.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2024-08-23 17:18:11.944459067 +0100
+++ 0072-fbarray-fix-lookahead-ignore-mask-handling.patch 2024-08-23 17:18:09.751430214 +0100
@@ -1 +1 @@
-From a344719c181aac28cb2ada0d2ddbfee8ad737a1a Mon Sep 17 00:00:00 2001
+From 0f46faa56ff6ccd95acd4ac2677370bee2e92200 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit a344719c181aac28cb2ada0d2ddbfee8ad737a1a ]
+
@@ -19 +20,0 @@
-Cc: stable at dpdk.org
@@ -29 +30 @@
-index 147d6e2a07..4b17ef6be3 100644
+index f448d4f196..38a62cd456 100644
@@ -71 +72 @@
-index b4f0b0b0c3..195f8394be 100644
+index 0013ef2c55..def47ceef0 100644
@@ -74 +75 @@
-@@ -217,4 +217,6 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
+@@ -220,4 +220,6 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
@@ -81 +82 @@
-@@ -226,9 +228,14 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
+@@ -229,9 +231,14 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
@@ -98 +99 @@
-@@ -236,5 +243,5 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
+@@ -239,5 +246,5 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
More information about the stable
mailing list