From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW0tq-00021D-GJ for qemu-devel@nongnu.org; Fri, 04 Apr 2014 05:59:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WW0ti-0004nb-Vp for qemu-devel@nongnu.org; Fri, 04 Apr 2014 05:59:02 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:58050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW0th-0004mx-Ug for qemu-devel@nongnu.org; Fri, 04 Apr 2014 05:58:54 -0400 From: Date: Fri, 4 Apr 2014 17:58:01 +0800 Message-ID: <1396605482-8720-10-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1396605482-8720-1-git-send-email-arei.gonglei@huawei.com> References: <1396605482-8720-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v5 09/10] migration: optimize xbzrle by reducing data copy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: ChenLiang , weidong.huang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, owasserm@redhat.com, Gonglei , pbonzini@redhat.com From: ChenLiang Reducing data copy can reduce cpu overhead. 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 84a4bd3..94b62e2 100644 --- a/arch_init.c +++ b/arch_init.c @@ -373,11 +373,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); if (encoded_len == 0) { @@ -396,7 +393,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