From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN3Vy-0001Er-So for qemu-devel@nongnu.org; Fri, 20 Sep 2013 12:25:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VN3Vs-0006Qy-Lt for qemu-devel@nongnu.org; Fri, 20 Sep 2013 12:25:06 -0400 Received: from mail-ea0-x235.google.com ([2a00:1450:4013:c01::235]:55549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN3Vs-0006P7-Eq for qemu-devel@nongnu.org; Fri, 20 Sep 2013 12:25:00 -0400 Received: by mail-ea0-f181.google.com with SMTP id d10so374638eaj.26 for ; Fri, 20 Sep 2013 09:24:59 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 20 Sep 2013 18:24:40 +0200 Message-Id: <1379694292-1601-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1379694292-1601-1-git-send-email-pbonzini@redhat.com> References: <1379694292-1601-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 01/13] exec: always use MADV_DONTFORK List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Andrea Arcangeli , Gleb Natapov From: Andrea Arcangeli 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 Tested-By: Benoit Canet Acked-by: Paolo Bonzini Signed-off-by: Gleb Natapov --- exec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/exec.c b/exec.c index 030118e..5e6015c 100644 --- a/exec.c +++ b/exec.c @@ -1157,6 +1157,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); -- 1.8.3.1