[dpdk-stable] patch 'test/common: fix log2 check' has been queued to stable release 19.11.1

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue Feb 11 12:19:12 CET 2020


Hi,

FYI, your patch has been queued to stable release 19.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/13/20. 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.

Thanks.

Luca Boccassi

---
>From 80e5c632b72b582777a8615d7a2cb660b8425b27 Mon Sep 17 00:00:00 2001
From: David Marchand <david.marchand at redhat.com>
Date: Fri, 20 Dec 2019 15:01:49 +0100
Subject: [PATCH] test/common: fix log2 check

[ upstream commit 30a0df64aaed5cbf33fd5d237d5812cee1cc0ef9 ]

We recently started to get random failures on the common_autotest ut with
clang on Ubuntu 16.04.6.

Example: https://travis-ci.com/DPDK/dpdk/jobs/263177424

Wrong rte_log2_u64(0) val 0, expected ffffffff
Test Failed

The ut passes 0 to log2() to get an expected value.

Quoting log2 / log(3) manual:
If x is zero, then a pole error occurs, and the functions return
-HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively.

rte_log2_uXX helpers handle 0 as a special value and return 0.
Let's have dedicated tests for this case.

Fixes: 05c4345ef5c2 ("test: add unit test for integer log2 function")

Signed-off-by: David Marchand <david.marchand at redhat.com>
Acked-by: Aaron Conole <aconole at redhat.com>
---
 app/test/test_common.c                     | 14 +++++++++++++-
 lib/librte_eal/common/include/rte_common.h |  6 ++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/app/test/test_common.c b/app/test/test_common.c
index 2b856f8ba5..12bd1cad90 100644
--- a/app/test/test_common.c
+++ b/app/test/test_common.c
@@ -216,7 +216,19 @@ test_log2(void)
 	const uint32_t max = 0x10000;
 	const uint32_t step = 1;
 
-	for (i = 0; i < max; i = i + step) {
+	compare = rte_log2_u32(0);
+	if (compare != 0) {
+		printf("Wrong rte_log2_u32(0) val %x, expected 0\n", compare);
+		return TEST_FAILED;
+	}
+
+	compare = rte_log2_u64(0);
+	if (compare != 0) {
+		printf("Wrong rte_log2_u64(0) val %x, expected 0\n", compare);
+		return TEST_FAILED;
+	}
+
+	for (i = 1; i < max; i = i + step) {
 		uint64_t i64;
 
 		/* extend range for 64-bit */
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 459d082d14..c352838073 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -538,6 +538,9 @@ rte_bsf32_safe(uint64_t v, uint32_t *pos)
 /**
  * Return the rounded-up log2 of a integer.
  *
+ * @note Contrary to the logarithm mathematical operation,
+ * rte_log2_u32(0) == 0 and not -inf.
+ *
  * @param v
  *     The input parameter.
  * @return
@@ -632,6 +635,9 @@ rte_fls_u64(uint64_t x)
 /**
  * Return the rounded-up log2 of a 64-bit integer.
  *
+ * @note Contrary to the logarithm mathematical operation,
+ * rte_log2_u64(0) == 0 and not -inf.
+ *
  * @param v
  *     The input parameter.
  * @return
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-02-11 11:17:39.145096561 +0000
+++ 0006-test-common-fix-log2-check.patch	2020-02-11 11:17:38.303999552 +0000
@@ -1,8 +1,10 @@
-From 30a0df64aaed5cbf33fd5d237d5812cee1cc0ef9 Mon Sep 17 00:00:00 2001
+From 80e5c632b72b582777a8615d7a2cb660b8425b27 Mon Sep 17 00:00:00 2001
 From: David Marchand <david.marchand at redhat.com>
 Date: Fri, 20 Dec 2019 15:01:49 +0100
 Subject: [PATCH] test/common: fix log2 check
 
+[ upstream commit 30a0df64aaed5cbf33fd5d237d5812cee1cc0ef9 ]
+
 We recently started to get random failures on the common_autotest ut with
 clang on Ubuntu 16.04.6.
 
@@ -21,7 +23,6 @@
 Let's have dedicated tests for this case.
 
 Fixes: 05c4345ef5c2 ("test: add unit test for integer log2 function")
-Cc: stable at dpdk.org
 
 Signed-off-by: David Marchand <david.marchand at redhat.com>
 Acked-by: Aaron Conole <aconole at redhat.com>


More information about the stable mailing list