>From 8e7cd9425417189f5fc894039a8af956ca2e19dd Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Thu, 21 Apr 2016 22:19:16 +0200 Subject: [PATCH 3/3] util/mmap-alloc: preserve size alignment with guard pages on ARM Commit 9fac18f03a90 ("oslib: allocate PROT_NONE pages on top of RAM") introduced a guard page after the user-requested area. (Commit 794e8f301a17 ("exec: factor out duplicate mmap code") factored out this logic, preserving the behavior of 9fac18f03a90.) Christoffer reports that 9fac18f03a90 renders the KVM/ARM performance optimization added in 2e07b297e0b4 ("oslib-posix: Align to permit transparent hugepages on ARM Linux") ineffective, because the single guard page makes the size of the region unaligned, preventing the application of THP. Restore 2e07b297e0b4 to working state by aligning the full area size -- consisting of user requested and guard pages -- on ARM. Ref: http://thread.gmane.org/gmane.comp.emulators.qemu/407833 Reported-by: Christoffer Dall Signed-off-by: Laszlo Ersek --- util/mmap-alloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 41e36f74d7be..153a586cec63 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -41,7 +41,11 @@ size_t qemu_fd_getpagesize(int fd) static size_t size_with_guard_pages(size_t size, size_t align) { +#if defined(__arm__) + return QEMU_ALIGN_UP(size + getpagesize(), align); +#else return size + getpagesize(); +#endif } void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) -- 1.8.3.1