[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 18/38] exec: always use MADV_DONTFORK

From: Michael Roth
Subject: [Qemu-devel] [PATCH 18/38] exec: always use MADV_DONTFORK
Date: Wed, 25 Sep 2013 07:57:46 -0500

From: Andrea Arcangeli <address@hidden>

MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
overcommit heuristics decides there's too much anonymous virtual
memory allocated. If the KVM secondary MMU is synchronized with MMU
notifiers or not, doesn't make a difference in that regard.

Secondly it's always more efficient to avoid copying the guest
physical address space in the fork child (so we avoid to mark all the
guest memory readonly in the parent and so we skip the establishment
and teardown of lots of pagetables in the child).

In the common case we can ignore the error if MADV_DONTFORK is not
available. Leave a second invocation that errors out in the KVM path
if MMU notifiers are missing and KVM is enabled, to abort in such

Signed-off-by: Andrea Arcangeli <address@hidden>
Tested-By: Benoit Canet <address@hidden>
Acked-by: Paolo Bonzini <address@hidden>
Signed-off-by: Gleb Natapov <address@hidden>
(cherry picked from commit 3e469dbfe413c25d48321c3a19ddfae0727dc6e5)

Signed-off-by: Michael Roth <address@hidden>
 exec.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/exec.c b/exec.c
index 394f7e2..2ea8f04 100644
--- a/exec.c
+++ b/exec.c
@@ -1172,6 +1172,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void 
     qemu_ram_setup_dump(new_block->host, size);
     qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE);
+    qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK);
     if (kvm_enabled())
         kvm_setup_guest_memory(new_block->host, size);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]