[dpdk-stable] patch 'mem: limit use of address hint' has been queued to LTS release 18.11.2

Kevin Traynor ktraynor at redhat.com
Thu Apr 25 17:40:13 CEST 2019


Hi,

FYI, your patch has been queued to LTS release 18.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 05/01/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 can be viewed on the 18.11 branch at:
	https://github.com/kevintraynor/dpdk-stable-queue.git

Thanks.

Kevin Traynor

---
>From 558509fbb2b0a0f5803f348634e4956ff8cb5214 Mon Sep 17 00:00:00 2001
From: Shahaf Shuler <shahafs at mellanox.com>
Date: Sun, 31 Mar 2019 11:43:48 +0300
Subject: [PATCH] mem: limit use of address hint

[ upstream commit 237060c4ad15b4ee9002be3c0e56ac3070eceb48 ]

The commit below added an address hint as starting address for 64-bit
systems in case an explicit base virtual address was not set by the user.

The justification for such hint was to help devices that work in VA
mode and has a address range limitation to work smoothly with the eal
memory subsystem.

While the base address value selected may work fine for the eal
initialization, it easily breaks when trying to register external memory
using rte_extmem_register API.

Trying to register anonymous memory on RH x86_64 machine took several
minutes, during them the function eal_get_virtual_area repeatedly
scanned for a good VA candidate.

The attempt to guess which VA address will be free for mapping will
always result in not portable, error prone code:
* different application may use different libraries along w/ DPDK. One
  can never guess which library was called first and how much virtual
  memory it consumed.
* external memory can be registered at any time in the application run
  time.

In order not to break the existing secondary process design, this patch
only limits the max number of tries that will be done with the
address hint.
When the number of tries exceeds the threshold the code
will use the suggested address from kernel.

Fixes: 1df21702873d ("mem: use address hint for mapping hugepages")

Signed-off-by: Shahaf Shuler <shahafs at mellanox.com>
Tested-by: Anatoly Burakov <anatoly.burakov at intel.com>
Acked-by: Alejandro Lucero <alejandro.lucero at netronome.com>
---
 lib/librte_eal/common/eal_common_memory.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 999ba24b4..e3ef3714e 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -56,4 +56,5 @@ static uint64_t baseaddr = 0x100000000;
 #endif
 
+#define MAX_MMAP_WITH_DEFINED_ADDR_TRIES 5
 void *
 eal_get_virtual_area(void *requested_addr, size_t *size,
@@ -63,4 +64,5 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
 	uint64_t map_sz;
 	void *mapped_addr, *aligned_addr;
+	uint8_t try = 0;
 
 	if (system_page_sz == 0)
@@ -118,9 +120,12 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
 		if (mapped_addr != MAP_FAILED && addr_is_hint &&
 		    mapped_addr != requested_addr) {
-			/* hint was not used. Try with another offset */
-			munmap(mapped_addr, map_sz);
-			mapped_addr = MAP_FAILED;
+			try++;
 			next_baseaddr = RTE_PTR_ADD(next_baseaddr, page_sz);
-			requested_addr = next_baseaddr;
+			if (try <= MAX_MMAP_WITH_DEFINED_ADDR_TRIES) {
+				/* hint was not used. Try with another offset */
+				munmap(mapped_addr, map_sz);
+				mapped_addr = MAP_FAILED;
+				requested_addr = next_baseaddr;
+			}
 		}
 	} while ((allow_shrink || addr_is_hint) &&
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-04-25 16:37:48.395043705 +0100
+++ 0038-mem-limit-use-of-address-hint.patch	2019-04-25 16:37:46.747294903 +0100
@@ -1 +1 @@
-From 237060c4ad15b4ee9002be3c0e56ac3070eceb48 Mon Sep 17 00:00:00 2001
+From 558509fbb2b0a0f5803f348634e4956ff8cb5214 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 237060c4ad15b4ee9002be3c0e56ac3070eceb48 ]
+
@@ -36 +37,0 @@
-Cc: stable at dpdk.org
@@ -46 +47 @@
-index c9da69b16..5ae8d0124 100644
+index 999ba24b4..e3ef3714e 100644
@@ -49 +50 @@
-@@ -57,4 +57,5 @@ static uint64_t baseaddr = 0x100000000;
+@@ -56,4 +56,5 @@ static uint64_t baseaddr = 0x100000000;
@@ -55 +56 @@
-@@ -64,4 +65,5 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
+@@ -63,4 +64,5 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
@@ -61 +62 @@
-@@ -119,9 +121,12 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
+@@ -118,9 +120,12 @@ eal_get_virtual_area(void *requested_addr, size_t *size,


More information about the stable mailing list