From patchwork Fri Apr 22 11:12:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 613551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qrtJ12GqJz9sD3 for ; Fri, 22 Apr 2016 21:12:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=GusIfqfS; dkim-atps=neutral Received: from localhost ([::1]:59364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atZ0h-00082s-CU for incoming@patchwork.ozlabs.org; Fri, 22 Apr 2016 07:12:31 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lrZUEuH85IeICEaxYrLw/xk4S/Q/vbd0A+/bML2OTsc=; b=GusIfqfSI0qwpqd6INRKxaamRniw26ON1OnL1xyxuWTegf+3J8HMaPE+5h92ljKpSx 5mBNjeu/7QE27kwrtYCMbotI+G2OVRspD1d4I/8xqbQcRLDO9/xydgxSWjcrc1GEeikR Q4H/8ivsSXa93G5rvuQ/vEfy+Q1Bv4YHLXsTc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lrZUEuH85IeICEaxYrLw/xk4S/Q/vbd0A+/bML2OTsc=; b=cxcTy59p2cPd3WfXwrT/ZMK6N/byaURmiyLgCO5RVlfy78agc4+oJPRjLAnuSOM6i+ q1HlBojIx5sIKz2vQUdP8bOU4bcHxGSSGL83PoXNA7qS1ImR5RsB5CD/v0PQcytM3C0Q d5aueLZkosdsJCAwW9V+gro+QVAcZbXLCEf3U6w563Cj1LhHAaCOQ2qhOd+1Cr+NIZv8 Tudyje4uua9M7y6CTJ6AV8JvBnJcc2km/AaN9cIk3vSh9RSW+2UJwo76g+O4N2IdvGYA 6KbvMC8rm3Q9jE1Zr/z+mtVR6lI1Ltca4WXQq8nm3B7/PBIcbNzREpm0xNSmmt94cyo9 Rs4A== X-Gm-Message-State: AOPr4FUE0f7/Ej02tS/q0VcVOVmg156XIUgN1w7aTiMRurRQJWRt1/LiPapRK83xcBOLfECE X-Received: by 10.194.63.226 with SMTP id j2mr19569646wjs.27.1461323526420; Fri, 22 Apr 2016 04:12:06 -0700 (PDT) Received: from localhost.localdomain ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id s6sm7569387wjy.31.2016.04.22.04.12.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Apr 2016 04:12:05 -0700 (PDT) From: Christoffer Dall To: qemu-devel@nongnu.org Date: Fri, 22 Apr 2016 13:12:09 +0200 Message-Id: <1461323529-30724-1-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1461321267-32747-1-git-send-email-christoffer.dall@linaro.org> References: <1461321267-32747-1-git-send-email-christoffer.dall@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 Subject: [Qemu-devel] [PATCH v2] util: align memory allocations to 2M on AArch64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Michael S. Tsirkin" , Marc Zyngier , Alexander Graf , Christoffer Dall , Laszlo Ersek , shihwei@cs.columbia.edu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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. */