[dpdk-stable] patch 'reciprocal: fix off-by-one with 32-bit divisor' has been queued to LTS release 18.11.6

Kevin Traynor ktraynor at redhat.com
Tue Dec 10 15:58:54 CET 2019


Hi,

FYI, your patch has been queued to LTS release 18.11.6

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

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable-queue/commit/28450d0732da46af14c4f39ef38a3db5a20cb478

Thanks.

Kevin.

---
>From 28450d0732da46af14c4f39ef38a3db5a20cb478 Mon Sep 17 00:00:00 2001
From: Pavan Nikhilesh <pbhagavatula at marvell.com>
Date: Wed, 4 Sep 2019 00:46:45 +0530
Subject: [PATCH] reciprocal: fix off-by-one with 32-bit divisor

[ upstream commit 9b0a1dadc345805ca9d7428a977da080d5eee7e2 ]

Fix off-by-one error in 64bit reciprocal division when divisor is 32bit.

Caught with the unit test:

RTE>>reciprocal_division
Validating unsigned 32bit division.
Validating unsigned 64bit division.
Validating unsigned 64bit division with 32bit divisor.
Division failed, 16983222950483802557/819 = expected 20736535959076681
result 20736535959076682
Validating division by power of 2.
Test Failed

Fixes: 6d45659eacb8 ("eal: add u64-bit variant for reciprocal divide")

Signed-off-by: Pavan Nikhilesh <pbhagavatula at marvell.com>
---
 lib/librte_eal/common/rte_reciprocal.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/rte_reciprocal.c b/lib/librte_eal/common/rte_reciprocal.c
index f017d0c28..1c6d10e73 100644
--- a/lib/librte_eal/common/rte_reciprocal.c
+++ b/lib/librte_eal/common/rte_reciprocal.c
@@ -134,10 +134,13 @@ rte_reciprocal_value_u64(uint64_t d)
 	struct rte_reciprocal_u64 R;
 	uint64_t m;
+	uint64_t r;
 	int l;
 
 	l = 63 - __builtin_clzll(d);
 
-	m = divide_128_div_64_to_64((1ULL << l), 0, d, NULL) << 1;
-	m = (1ULL << l) - d ? m + 2 : 1;
+	m = divide_128_div_64_to_64((1ULL << l), 0, d, &r) << 1;
+	if (r << 1 < r || r << 1 >= d)
+		m++;
+	m = (1ULL << l) - d ? m + 1 : 1;
 	R.m = m;
 
-- 
2.21.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-12-10 14:49:40.427435154 +0000
+++ 0020-reciprocal-fix-off-by-one-with-32-bit-divisor.patch	2019-12-10 14:49:39.012458513 +0000
@@ -1 +1 @@
-From 9b0a1dadc345805ca9d7428a977da080d5eee7e2 Mon Sep 17 00:00:00 2001
+From 28450d0732da46af14c4f39ef38a3db5a20cb478 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 9b0a1dadc345805ca9d7428a977da080d5eee7e2 ]
+
@@ -20 +21,0 @@
-Cc: stable at dpdk.org



More information about the stable mailing list