All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK
@ 2013-07-25 10:11 Andrea Arcangeli
  2013-07-25 10:16 ` Peter Maydell
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Andrea Arcangeli @ 2013-07-25 10:11 UTC (permalink / raw)
  To: qemu-devel, qemu-stable; +Cc: Paolo Bonzini, Gleb Natapov

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
case.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---
 exec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/exec.c b/exec.c
index c99a883..d3bb58d 100644
--- a/exec.c
+++ b/exec.c
@@ -1162,6 +1162,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
 
     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);

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-09-01  9:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25 10:11 [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK Andrea Arcangeli
2013-07-25 10:16 ` Peter Maydell
2013-07-25 10:32   ` Andrea Arcangeli
2013-08-06 16:55     ` Andreas Färber
2013-08-30 15:48       ` Paolo Bonzini
2013-08-06 16:47 ` [Qemu-devel] PING for-1.6 " Paolo Bonzini
2013-08-30 15:48   ` [Qemu-devel] PING^2 " Paolo Bonzini
2013-08-30 15:52     ` Andreas Färber
2013-08-30 16:03       ` Paolo Bonzini
2013-08-30 16:21         ` Gleb Natapov
2013-08-30 16:40           ` Paolo Bonzini
2013-08-06 17:06 ` [Qemu-devel] " Benoît Canet
2013-09-01  9:39 ` Gleb Natapov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.