From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by dpdk.org (Postfix) with ESMTP id 585095B3C for ; Mon, 30 Jul 2018 18:21:45 +0200 (CEST) Received: from 1.general.paelzer.uk.vpn ([10.172.196.172] helo=lap.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkArR-00009D-SD; Mon, 30 Jul 2018 16:17:29 +0000 From: Christian Ehrhardt To: Anatoly Burakov Cc: Lei Yao , Dariusz Stojaczyk , dpdk stable Date: Mon, 30 Jul 2018 18:12:32 +0200 Message-Id: <20180730161342.16566-107-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730161342.16566-1-christian.ehrhardt@canonical.com> References: <20180730161342.16566-1-christian.ehrhardt@canonical.com> Subject: [dpdk-stable] patch 'mem: fix alignment of requested virtual areas' has been queued to stable release 18.05.1 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: , X-List-Received-Date: Mon, 30 Jul 2018 16:21:45 -0000 Hi, FYI, your patch has been queued to stable release 18.05.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 08/01/18. So please shout if anyone has objections. Thanks. Christian Ehrhardt --- >>From a132f9990766c2fdb0a6895614bd37f91038d966 Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Mon, 16 Jul 2018 15:57:19 +0100 Subject: [PATCH] mem: fix alignment of requested virtual areas [ upstream commit d5dd22c9f6ba86ce9175d84a8f95946edbdb04fc ] The original code did not align any addresses that were requested as page-aligned, but were different because addr_is_hint was set. Below fix by Dariusz has introduced an issue where all unaligned addresses were left as unaligned. This patch is a partial revert of commit 7fa7216ed48d ("mem: fix alignment of requested virtual areas") and implements a proper fix for this issue, by asking for alignment in all but the following two cases: 1) page size is equal to system page size, or 2) we got an aligned requested address, and will not accept a different one This ensures that alignment is performed in all cases, except for those we can guarantee that the address will not need alignment. Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory") Fixes: 7fa7216ed48d ("mem: fix alignment of requested virtual areas") Signed-off-by: Anatoly Burakov Tested-by: Lei Yao Acked-by: Dariusz Stojaczyk --- lib/librte_eal/common/eal_common_memory.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c index ecc5bb248..341c28ad7 100644 --- a/lib/librte_eal/common/eal_common_memory.c +++ b/lib/librte_eal/common/eal_common_memory.c @@ -63,14 +63,17 @@ eal_get_virtual_area(void *requested_addr, size_t *size, addr_is_hint = true; } - /* if requested address is not aligned by page size, or if requested - * address is NULL, add page size to requested length as we may get an - * address that's aligned by system page size, which can be smaller than - * our requested page size. additionally, we shouldn't try to align if - * system page size is the same as requested page size. + /* we don't need alignment of resulting pointer in the following cases: + * + * 1. page size is equal to system size + * 2. we have a requested address, and it is page-aligned, and we will + * be discarding the address if we get a different one. + * + * for all other cases, alignment is potentially necessary. */ no_align = (requested_addr != NULL && - ((uintptr_t)requested_addr & (page_sz - 1)) == 0) || + requested_addr == RTE_PTR_ALIGN(requested_addr, page_sz) && + !addr_is_hint) || page_sz == system_page_sz; do { -- 2.17.1