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: 66434 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp655479qge; Fri, 22 Apr 2016 04:12:42 -0700 (PDT) X-Received: by 10.55.192.197 with SMTP id v66mr4139847qkv.146.1461323562536; Fri, 22 Apr 2016 04:12:42 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o140si3172613qke.179.2016.04.22.04.12.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Apr 2016 04:12:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atZ0s-00082s-4B for patch@linaro.org; Fri, 22 Apr 2016 07:12:42 -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+patch=linaro.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(-) -- 2.1.2.330.g565301e.dirty 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. */