From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6kgc-00057p-8f for qemu-devel@nongnu.org; Tue, 06 Aug 2013 13:04:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6kgU-0002Qi-N0 for qemu-devel@nongnu.org; Tue, 06 Aug 2013 13:04:42 -0400 Date: Tue, 6 Aug 2013 19:06:20 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20130806170619.GD5068@irqsave.net> References: <1374747075-7172-1-git-send-email-aarcange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1374747075-7172-1-git-send-email-aarcange@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] KVM: always use MADV_DONTFORK List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrea Arcangeli Cc: Paolo Bonzini , qemu-devel@nongnu.org, Gleb Natapov , qemu-stable@nongnu.org Le Thursday 25 Jul 2013 =E0 12:11:15 (+0200), Andrea Arcangeli a =E9crit = : > 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. >=20 > 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). >=20 > 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. >=20 > Signed-off-by: Andrea Arcangeli > --- > exec.c | 1 + > 1 file changed, 1 insertion(+) >=20 > 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 siz= e, void *host, > =20 > 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); > =20 > if (kvm_enabled()) > kvm_setup_guest_memory(new_block->host, size); >=20 This patch solve a bug where the network down script of a regular tap int= erface is not executed because fork fail when a pci-assigment is done on a large= guest. Tested-By: Benoit Canet