From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atZ0O-0007Pc-9g for qemu-devel@nongnu.org; Fri, 22 Apr 2016 07:12:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1atZ0J-0001jE-Qm for qemu-devel@nongnu.org; Fri, 22 Apr 2016 07:12:12 -0400 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:37320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atZ0J-0001j7-DT for qemu-devel@nongnu.org; Fri, 22 Apr 2016 07:12:07 -0400 Received: by mail-wm0-x234.google.com with SMTP id n3so21545534wmn.0 for ; Fri, 22 Apr 2016 04:12:07 -0700 (PDT) From: Christoffer Dall Date: Fri, 22 Apr 2016 13:12:09 +0200 Message-Id: <1461323529-30724-1-git-send-email-christoffer.dall@linaro.org> In-Reply-To: <1461321267-32747-1-git-send-email-christoffer.dall@linaro.org> References: <1461321267-32747-1-git-send-email-christoffer.dall@linaro.org> Subject: [Qemu-devel] [PATCH v2] util: align memory allocations to 2M on AArch64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexander Graf , Marc Zyngier , Laszlo Ersek , "Michael S. Tsirkin" , shihwei@cs.columbia.edu, Christoffer Dall For KVM to use Transparent Huge Pages (THP) we have to ensure that the alignment of the userspace address of the KVM memory slot and the IPA that the guest sees for a memory region have the same offset from the 2M huge page size boundary. One way to achieve this is to always align the IPA region at a 2M boundary and ensure that the mmap alignment is also at 2M. Unfortunately, we were only doing this for __arm__, not for __aarch64__, so add this simply condition. This fixes a performance regression using KVM/ARM on AArch64 platforms that showed a performance penalty of more than 50%, introduced by the following commit: 9fac18f (oslib: allocate PROT_NONE pages on top of RAM, 2015-09-10) We were only lucky before the above commit, because we were allocating large regions and naturally getting a 2M alignment on those allocations then. Reported-by: Shih-Wei Li Signed-off-by: Christoffer Dall --- The first version of this patch was accidentally made against the v2.5.0 release instead of master, so this is a rebased version. util/oslib-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 20ca141..a0c5b91 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -26,7 +26,7 @@ * THE SOFTWARE. */ -#if defined(__linux__) && (defined(__x86_64__) || defined(__arm__)) +#if defined(__linux__) && (defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)) /* Use 2 MiB alignment so transparent hugepages can be used by KVM. Valgrind does not support alignments larger than 1 MiB, therefore we need special code which handles running on Valgrind. */ -- 2.1.2.330.g565301e.dirty