From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMGuJ-0006VC-Gq for qemu-devel@nongnu.org; Wed, 18 Sep 2013 08:31:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMGuB-0001Qj-Ja for qemu-devel@nongnu.org; Wed, 18 Sep 2013 08:30:59 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:56967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMGuB-0001Pv-C5 for qemu-devel@nongnu.org; Wed, 18 Sep 2013 08:30:51 -0400 Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Sep 2013 06:30:47 -0600 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 8545E19D8036 for ; Wed, 18 Sep 2013 06:30:44 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8ICUiWu231210 for ; Wed, 18 Sep 2013 06:30:45 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r8ICUhkI029070 for ; Wed, 18 Sep 2013 06:30:44 -0600 Message-ID: <52399CF2.6000508@linux.vnet.ibm.com> Date: Wed, 18 Sep 2013 08:30:42 -0400 From: "Michael R. Hines" MIME-Version: 1.0 References: <63cb8b20f633a6abe56d384e3c3a5151ee6f422d.1379498467.git.yamahata@private.email.ne.jp> In-Reply-To: <63cb8b20f633a6abe56d384e3c3a5151ee6f422d.1379498467.git.yamahata@private.email.ne.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] migration: ram_handle_compressed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: quintela@redhat.com, qemu-devel@nongnu.org, owasserm@redhat.com, mrhines@us.ibm.com, pbonzini@redhat.com, chegu_vinod@hp.com On 09/18/2013 06:07 AM, Isaku Yamahata wrote: > ram_handle_compressed() should be aware size > TARGET_PAGE_SIZE > migration-rdma can call it with larger size. > > Signed-off-by: Isaku Yamahata > --- > arch_init.c | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > diff --git a/arch_init.c b/arch_init.c > index e47e139..64c81b0 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -844,15 +844,22 @@ static inline void *host_from_stream_offset(QEMUFile *f, > */ > void ram_handle_compressed(void *host, uint8_t ch, uint64_t size) > { > - if (ch != 0 || !is_zero_page(host)) { > - memset(host, ch, size); > + uint64_t pagesize = getpagesize(); > + while (size > 0) { > + uint64_t length = MIN(pagesize, size); > + > + if (ch !=0 || buffer_find_nonzero_offset(host, length) != length) { > + memset(host, ch, length); > #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()) && pagesize <= length) { > + qemu_madvise(host, size, QEMU_MADV_DONTNEED); > + } > #endif > + } > + > + size -= length; > + host += length; > } > } > What is the reason for breaking the madvise() into smaller pieces? - Michael