From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Un0uZ-00029R-SG for qemu-devel@nongnu.org; Thu, 13 Jun 2013 02:21:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Un0uX-0006U3-B5 for qemu-devel@nongnu.org; Thu, 13 Jun 2013 02:21:31 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:58780 helo=mx01.kamp.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Un0uX-0006SX-1g for qemu-devel@nongnu.org; Thu, 13 Jun 2013 02:21:29 -0400 Message-ID: <51B964E4.1020504@kamp.de> Date: Thu, 13 Jun 2013 08:21:24 +0200 From: Peter Lieven MIME-Version: 1.0 References: <1370859260-8183-1-git-send-email-pl@kamp.de> <1370859260-8183-3-git-send-email-pl@kamp.de> <51B93CBE.4040403@linux.vnet.ibm.com> In-Reply-To: <51B93CBE.4040403@linux.vnet.ibm.com> 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: Wenchao Xia Cc: quintela@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, owasserm@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au On 13.06.2013 05:30, Wenchao Xia wrote: > ÓÚ 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. It does not consume memory for normal pages and for thp since 3.8. BR, Peter