dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0018-exec-always-use-MADV_DONTFORK.patch

298366
From 57ea2d21ae1863fd4002b2aea8ea8db8e206d464 Mon Sep 17 00:00:00 2001
298366
From: Andrea Arcangeli <aarcange@redhat.com>
298366
Date: Thu, 25 Jul 2013 12:11:15 +0200
298366
Subject: [PATCH] exec: always use MADV_DONTFORK
298366
298366
MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
298366
overcommit heuristics decides there's too much anonymous virtual
298366
memory allocated. If the KVM secondary MMU is synchronized with MMU
298366
notifiers or not, doesn't make a difference in that regard.
298366
298366
Secondly it's always more efficient to avoid copying the guest
298366
physical address space in the fork child (so we avoid to mark all the
298366
guest memory readonly in the parent and so we skip the establishment
298366
and teardown of lots of pagetables in the child).
298366
298366
In the common case we can ignore the error if MADV_DONTFORK is not
298366
available. Leave a second invocation that errors out in the KVM path
298366
if MMU notifiers are missing and KVM is enabled, to abort in such
298366
case.
298366
298366
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
298366
Tested-By: Benoit Canet <benoit@irqsave.net>
298366
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
298366
Signed-off-by: Gleb Natapov <gleb@redhat.com>
298366
(cherry picked from commit 3e469dbfe413c25d48321c3a19ddfae0727dc6e5)
298366
298366
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
298366
---
298366
 exec.c | 1 +
298366
 1 file changed, 1 insertion(+)
298366
298366
diff --git a/exec.c b/exec.c
298366
index 394f7e2..2ea8f04 100644
298366
--- a/exec.c
298366
+++ b/exec.c
298366
@@ -1172,6 +1172,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
298366
 
298366
     qemu_ram_setup_dump(new_block->host, size);
298366
     qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
298366
+    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
298366
 
298366
     if (kvm_enabled())
298366
         kvm_setup_guest_memory(new_block->host, size);