From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ly46L-0000lB-2J for qemu-devel@nongnu.org; Sun, 26 Apr 2009 09:08:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ly46F-0000kz-Iy for qemu-devel@nongnu.org; Sun, 26 Apr 2009 09:08:55 -0400 Received: from [199.232.76.173] (port=51853 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ly46F-0000kw-EF for qemu-devel@nongnu.org; Sun, 26 Apr 2009 09:08:51 -0400 Received: from mx2.redhat.com ([66.187.237.31]:49194) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ly46E-0006I4-UI for qemu-devel@nongnu.org; Sun, 26 Apr 2009 09:08:51 -0400 Message-ID: <49F45CDB.205@redhat.com> Date: Sun, 26 Apr 2009 16:08:43 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] kvm: Avoid COW if KVM MMU is asynchronous References: <49F451B9.8040205@web.de> In-Reply-To: <49F451B9.8040205@web.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Gleb Natapov , qemu-devel Jan Kiszka wrote: > If the KVM MMU is asynchronous (kernel does not support MMU_NOTIFIER), > we have to avoid COW for the guest memory. Otherwise we risk serious > breakage when guest pages change there physical locations due to COW > after fork. Seen when forking smbd during runtime via -smb. > > Signed-off-by: Jan Kiszka > --- > > exec.c | 14 ++++++++++++++ > 1 files changed, 14 insertions(+), 0 deletions(-) > > diff --git a/exec.c b/exec.c > index 23013fb..ce0603e 100644 > --- a/exec.c > +++ b/exec.c > @@ -2477,6 +2477,20 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size) > new_block->next = ram_blocks; > ram_blocks = new_block; > > + if (kvm_enabled() && !kvm_has_sync_mmu()) { > +#ifdef MADV_DONTFORK > + int ret = madvise(new_block->host, size, MADV_DONTFORK); > + if (ret) { > + perror("madvice"); > + exit(1); > + } > +#else > + fprintf(stderr, > + "Need MADV_DONTFORK in absence of synchronous KVM MMU\n"); > + exit(1); > +#endif > + } > + Suggest wrapping in a function and hiding it deep inside kvm-all.c. -- error compiling committee.c: too many arguments to function