[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support
From: |
Avi Kivity |
Subject: |
Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support |
Date: |
Thu, 11 Mar 2010 17:52:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Thunderbird/3.0.3 |
On 03/11/2010 05:14 PM, Andrea Arcangeli wrote:
From: Andrea Arcangeli<address@hidden>
This will allow proper alignment so NPT/EPT can take advantage of linux host
backing the guest memory with hugepages (only relevant for KVM and not for QEMU
that has no NPT/EPT support). To complete it, it will also notify
the kernel that this memory is important to be backed by hugepages with
madvise (needed for both KVM and QEMU).
Signed-off-by: Andrea Arcangeli<address@hidden>
---
diff --git a/exec.c b/exec.c
index 891e0ee..aedd133 100644
--- a/exec.c
+++ b/exec.c
@@ -2628,11 +2628,25 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)
PROT_EXEC|PROT_READ|PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
#else
- new_block->host = qemu_vmalloc(size);
-#endif
+#if defined(__linux__)&& defined(TARGET_HPAGE_BITS)
+ if (!kvm_enabled())
+#endif
+ new_block->host = qemu_vmalloc(size);
+#if defined(__linux__)&& defined(TARGET_HPAGE_BITS)
+ else
+ /*
+ * Align on HPAGE_SIZE so "(gfn ^ pfn)&
+ * (HPAGE_SIZE-1) == 0" to allow KVM to take advantage
+ * of hugepages with NPT/EPT.
+ */
+ new_block->host = qemu_memalign(1<< TARGET_HPAGE_BITS, size);
That is a little wasteful. How about a hint to mmap() requesting proper
alignment (MAP_HPAGE_ALIGN)?
Failing that, modify qemu_memalign() to trim excess memory.
Come to think of it, posix_memalign() needs to do that (but doesn't).
+#endif
#ifdef MADV_MERGEABLE
madvise(new_block->host, size, MADV_MERGEABLE);
#endif
+#ifdef MADV_HUGEPAGE
+ madvise(new_block->host, size, MADV_HUGEPAGE);
+#endif
}
--
error compiling committee.c: too many arguments to function
- [Qemu-devel] [PATCH QEMU] transparent hugepage support, Andrea Arcangeli, 2010/03/11
- Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support,
Avi Kivity <=
- Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support, Paul Brook, 2010/03/11
- Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support, Andrea Arcangeli, 2010/03/11
- Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support, Paul Brook, 2010/03/11
- Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support, Andrea Arcangeli, 2010/03/11
- Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support, Paul Brook, 2010/03/12
- Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support, Andrea Arcangeli, 2010/03/12
- Re: [Qemu-devel] [PATCH QEMU] transparent hugepage support, Paul Brook, 2010/03/12