From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK2iy-0006AV-LV for qemu-devel@nongnu.org; Fri, 15 Jan 2016 06:39:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK2iu-0006Qa-Hc for qemu-devel@nongnu.org; Fri, 15 Jan 2016 06:39:24 -0500 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:37665) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK2iu-0006QV-Ak for qemu-devel@nongnu.org; Fri, 15 Jan 2016 06:39:20 -0500 Received: by mail-wm0-x22b.google.com with SMTP id f206so20347301wmf.0 for ; Fri, 15 Jan 2016 03:39:20 -0800 (PST) Sender: Paolo Bonzini References: <1452851297-11198-1-git-send-email-liang.z.li@intel.com> From: Paolo Bonzini Message-ID: <5698DA5F.2040404@redhat.com> Date: Fri, 15 Jan 2016 12:39:11 +0100 MIME-Version: 1.0 In-Reply-To: <1452851297-11198-1-git-send-email-liang.z.li@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] migration: not send zero page header in ram bulk stage List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liang Li , qemu-devel@nongnu.org Cc: amit.shah@redhat.com, zhang.zhanghailiang@huawei.com, dgilbert@redhat.com, quintela@redhat.com On 15/01/2016 10:48, Liang Li wrote: > Now that VM's RAM pages are initialized to zero, (VM's RAM is allcated > with the mmap() and MAP_ANONYMOUS option, or mmap() without MAP_SHARED > if hugetlbfs is used.) so there is no need to send the zero page header > to destination. > > For guest just uses a small portions of RAM, this change can avoid > allocating all the guest's RAM pages in the destination node after > live migration. Another benefit is destination QEMU can save lots of > CPU cycles for zero page checking. > > Signed-off-by: Liang Li This does not work. Depending on the board, some pages are written by QEMU before the guest starts. If the guest rewrites them with zeroes, this change breaks migration. Paolo > --- > migration/ram.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/migration/ram.c b/migration/ram.c > index 4e606ab..c4821d1 100644 > --- a/migration/ram.c > +++ b/migration/ram.c > @@ -705,10 +705,12 @@ static int save_zero_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset, > > if (is_zero_range(p, TARGET_PAGE_SIZE)) { > acct_info.dup_pages++; > - *bytes_transferred += save_page_header(f, block, > - offset | RAM_SAVE_FLAG_COMPRESS); > - qemu_put_byte(f, 0); > - *bytes_transferred += 1; > + if (!ram_bulk_stage) { > + *bytes_transferred += save_page_header(f, block, offset | > + RAM_SAVE_FLAG_COMPRESS); > + qemu_put_byte(f, 0); > + *bytes_transferred += 1; > + } > pages = 1; > } > >