From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN1Ou-0006xy-Me for qemu-devel@nongnu.org; Fri, 20 Sep 2013 10:09:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VN1Oi-0005bL-NS for qemu-devel@nongnu.org; Fri, 20 Sep 2013 10:09:40 -0400 Received: from e32.co.us.ibm.com ([32.97.110.150]:51478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN1Oi-0005b2-5G for qemu-devel@nongnu.org; Fri, 20 Sep 2013 10:09:28 -0400 Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Sep 2013 08:09:26 -0600 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 29E613E40026 for ; Fri, 20 Sep 2013 08:09:25 -0600 (MDT) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8KE9D57228568 for ; Fri, 20 Sep 2013 08:09:14 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r8KE9D1P013111 for ; Fri, 20 Sep 2013 08:09:13 -0600 Message-ID: <523C56FE.7090303@linux.vnet.ibm.com> Date: Fri, 20 Sep 2013 10:09:02 -0400 From: "Michael R. Hines" MIME-Version: 1.0 References: <37844bd5ee04e7d9ba3dab8f06bdedc39c46c8f1.1379663427.git.yamahata@private.email.ne.jp> In-Reply-To: <37844bd5ee04e7d9ba3dab8f06bdedc39c46c8f1.1379663427.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 v2] migration: ram_handle_compressed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: owasserm@redhat.com, quintela@redhat.com, mrhines@us.ibm.com, qemu-devel@nongnu.org, pbonzini@redhat.com On 09/20/2013 03:51 AM, Isaku Yamahata wrote: > ram_handle_compressed() should be aware of size > TARGET_PAGE_SIZE. > migration-rdma can call it with larger size. > > Signed-off-by: Isaku Yamahata > --- > changes v1 -> v2: > - don't loop > --- > arch_init.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/arch_init.c b/arch_init.c > index e47e139..ab466fc 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -844,13 +844,14 @@ 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)) { > + if (ch != 0 || buffer_find_nonzero_offset(host, size) != size) { > memset(host, ch, 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())) { > + size = size & ~(getpagesize() - 1); > + if (size > 0) { > + qemu_madvise(host, size, QEMU_MADV_DONTNEED); > + } > } > #endif > } NACK. Why don't you modify the is_zero_page function *itself*? This seems like an overly complicated solution - just modify the is_zero_page function to pass along the size parameter and let buffer_find_nonzero_offset() run the same code. Fix the original problem - don't breakup the memory into smaller pieces..... - Michael