From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJKjG-00045G-Nr for qemu-devel@nongnu.org; Fri, 28 Feb 2014 05:31:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJKjB-0007a7-Vs for qemu-devel@nongnu.org; Fri, 28 Feb 2014 05:31:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22235) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJKjB-0007a1-Nl for qemu-devel@nongnu.org; Fri, 28 Feb 2014 05:31:37 -0500 Date: Fri, 28 Feb 2014 10:30:23 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20140228103022.GG2695@work-vm> References: <33183CC9F5247A488A2544077AF19020815D229D@SZXEMA503-MBS.china.huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <33183CC9F5247A488A2544077AF19020815D229D@SZXEMA503-MBS.china.huawei.com> Subject: Re: [Qemu-devel] [PATCH 6/7] migraion: optimiztion xbzrle by reducing data copy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gonglei (Arei)" Cc: "chenliang (T)" , Peter Maydell , Juan Quintela , "pl@kamp.de" , "qemu-devel@nongnu.org" , "aliguori@amazon.com" , "pbonzini@redhat.com" * Gonglei (Arei) (arei.gonglei@huawei.com) wrote: > Reducing data copy can reduce cpu overheah. (Note a few typos in subject/title) > Signed-off-by: ChenLiang > Signed-off-by: Gonglei > --- > arch_init.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/arch_init.c b/arch_init.c > index 2211e0b..cc88875 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -344,11 +344,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data, > > prev_cached_page = get_cached_data(XBZRLE.cache, current_addr); > > - /* save current buffer into memory */ > - memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE); > - > /* XBZRLE encoding (if there is no overflow) */ > - encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf, > + encoded_len = xbzrle_encode_buffer(prev_cached_page, *current_data, > TARGET_PAGE_SIZE, XBZRLE.encoded_buf, > TARGET_PAGE_SIZE); Is xbzrle_encode_buffer safe if the main memory is still being changed while it is run? Even with multiple CPUs changing it? Even on CPUs with looser memory ordering semantics? > if (encoded_len == 0) { > @@ -367,7 +364,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data, > > /* we need to update the data in the cache, in order to get the same data */ > if (!last_stage) { > - memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE); > + xbzrle_decode_buffer(XBZRLE.encoded_buf, encoded_len, prev_cached_page, > + TARGET_PAGE_SIZE); > } > > /* Send XBZRLE based compressed page */ > -- > 1.7.12.4 > > > Best regards, > -Gonglei > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK