]> git.proxmox.com Git - qemu.git/commitdiff
Call MADV_HUGEPAGE for guest RAM allocations
authorLuiz Capitulino <lcapitulino@redhat.com>
Fri, 5 Oct 2012 19:47:57 +0000 (16:47 -0300)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 22 Oct 2012 18:26:34 +0000 (13:26 -0500)
This makes it possible for QEMU to use transparent huge pages (THP)
when transparent_hugepage/enabled=madvise. Otherwise THP is only
used when it's enabled system wide.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
exec.c
osdep.h

diff --git a/exec.c b/exec.c
index c4ed6fdef1f445316d578bcca2df4233628afcb4..750008c4e132e2bdd991c818360150bedd046bf5 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -2571,6 +2571,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
     cpu_physical_memory_set_dirty_range(new_block->offset, size, 0xff);
 
     qemu_ram_setup_dump(new_block->host, size);
+    qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
 
     if (kvm_enabled())
         kvm_setup_guest_memory(new_block->host, size);
diff --git a/osdep.h b/osdep.h
index cb213e02953369023282af534df35704dd6b7100..c5fd3d91ff79c4f0562085183d550f998993e945 100644 (file)
--- a/osdep.h
+++ b/osdep.h
@@ -108,6 +108,11 @@ void qemu_vfree(void *ptr);
 #else
 #define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
 #endif
+#ifdef MADV_HUGEPAGE
+#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE
+#else
+#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
+#endif
 
 #elif defined(CONFIG_POSIX_MADVISE)