From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmyGN-0000tr-Lh for qemu-devel@nongnu.org; Wed, 12 Jun 2013 23:31:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UmyGM-00026w-L1 for qemu-devel@nongnu.org; Wed, 12 Jun 2013 23:31:51 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:41030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmyGL-00026l-WC for qemu-devel@nongnu.org; Wed, 12 Jun 2013 23:31:50 -0400 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Jun 2013 08:55:09 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id B13EA394004F for ; Thu, 13 Jun 2013 09:01:39 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5D3VXwe21168156 for ; Thu, 13 Jun 2013 09:01:34 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5D3VbBf006262 for ; Thu, 13 Jun 2013 13:31:38 +1000 Message-ID: <51B93CBE.4040403@linux.vnet.ibm.com> Date: Thu, 13 Jun 2013 11:30:06 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1370859260-8183-1-git-send-email-pl@kamp.de> <1370859260-8183-3-git-send-email-pl@kamp.de> In-Reply-To: <1370859260-8183-3-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCHv2 2/2] migration: do not overwrite zero pages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: quintela@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, owasserm@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au ÓÚ 2013-6-10 18:14, Peter Lieven дµÀ: > on incoming migration do not memset pages to zero if they already read as zero. > this will allocate a new zero page and consume memory unnecessarily. even > if we madvise a MADV_DONTNEED later this will only deallocate the memory > asynchronously. > > Signed-off-by: Peter Lieven > --- > arch_init.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/arch_init.c b/arch_init.c > index 08fccf6..cf4e1d5 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -832,14 +832,16 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) > } > > ch = qemu_get_byte(f); > - memset(host, ch, TARGET_PAGE_SIZE); > + if (ch != 0 || !is_zero_page(host)) { If incoming page is not zero, always memset. If incoming page is zero, then if on destination it is not zero, memset. Logic is OK. Only question is if the read operation in is_zero_page() consumes memory, as there are doubt in the discuss before. Any way this patch will not break migration in my opinion. Reviewed-by: Wenchao Xia > + memset(host, ch, TARGET_PAGE_SIZE); > #ifndef _WIN32 > - if (ch == 0 && > - (!kvm_enabled() || kvm_has_sync_mmu()) && > - getpagesize() <= TARGET_PAGE_SIZE) { > - qemu_madvise(host, TARGET_PAGE_SIZE, QEMU_MADV_DONTNEED); > - } > + if (ch == 0 && > + (!kvm_enabled() || kvm_has_sync_mmu()) && > + getpagesize() <= TARGET_PAGE_SIZE) { > + qemu_madvise(host, TARGET_PAGE_SIZE, QEMU_MADV_DONTNEED); > + } > #endif > + } > } else if (flags & RAM_SAVE_FLAG_PAGE) { > void *host; > -- Best Regards Wenchao Xia