summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoffer Dall <christoffer.dall@linaro.org>2016-04-22 13:12:09 +0200
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 20:03:50 -0600
commitac59ce0da8eb6340efb64bf5e505be44a951f9bc (patch)
tree0e5aac4ac877dc9b3ece67cd5c3a11fa722bd390
parent78bf17b51c2f66eb27645346b3a1dab56815bf72 (diff)
downloadhqemu-ac59ce0da8eb6340efb64bf5e505be44a951f9bc.zip
hqemu-ac59ce0da8eb6340efb64bf5e505be44a951f9bc.tar.gz
util: align memory allocations to 2M on AArch64
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 simple 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. Cc: qemu-stable@nongnu.org Reported-by: Shih-Wei Li <shihwei@cs.columbia.edu> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> [PMM: wrapped long line] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--util/oslib-posix.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 20ca141..6cc4b8f 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -26,7 +26,8 @@
* 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. */
OpenPOWER on IntegriCloud