From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 8F22DA05D3 for ; Thu, 25 Apr 2019 17:41:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 85F461B5F3; Thu, 25 Apr 2019 17:41:46 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 4AE2D1B5F3 for ; Thu, 25 Apr 2019 17:41:45 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFD64CCB97; Thu, 25 Apr 2019 15:41:44 +0000 (UTC) Received: from rh.redhat.com (unknown [10.36.116.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7226E5D9C6; Thu, 25 Apr 2019 15:41:43 +0000 (UTC) From: Kevin Traynor To: Shahaf Shuler Cc: Anatoly Burakov , Alejandro Lucero , dpdk stable Date: Thu, 25 Apr 2019 16:40:13 +0100 Message-Id: <20190425154037.28778-38-ktraynor@redhat.com> In-Reply-To: <20190425154037.28778-1-ktraynor@redhat.com> References: <20190425154037.28778-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 25 Apr 2019 15:41:44 +0000 (UTC) Subject: [dpdk-stable] patch 'mem: limit use of address hint' has been queued to LTS release 18.11.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 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 Tested-by: Anatoly Burakov Acked-by: Alejandro Lucero --- 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@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,