From patchwork Wed Jul 25 14:50:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orit Wasserman X-Patchwork-Id: 173197 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 412F12C0098 for ; Thu, 26 Jul 2012 01:16:02 +1000 (EST) Received: from localhost ([::1]:40931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su2wi-0001Im-85 for incoming@patchwork.ozlabs.org; Wed, 25 Jul 2012 10:52:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su2wI-0000TE-Ky for qemu-devel@nongnu.org; Wed, 25 Jul 2012 10:51:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Su2wD-0002n9-5m for qemu-devel@nongnu.org; Wed, 25 Jul 2012 10:51:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su2wC-0002n5-UE for qemu-devel@nongnu.org; Wed, 25 Jul 2012 10:51:45 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6PEpQ7m030888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Jul 2012 10:51:26 -0400 Received: from dhcp-1-120.tlv.redhat.com (vpn-201-149.tlv.redhat.com [10.35.201.149]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q6PEoLQY024922; Wed, 25 Jul 2012 10:51:23 -0400 From: Orit Wasserman To: qemu-devel@nongnu.org Date: Wed, 25 Jul 2012 17:50:34 +0300 Message-Id: <1343227834-5400-13-git-send-email-owasserm@redhat.com> In-Reply-To: <1343227834-5400-1-git-send-email-owasserm@redhat.com> References: <1343227834-5400-1-git-send-email-owasserm@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com, blauwirbel@gmail.com, chegu_vinod@hp.com, avi@redhat.com, pbonzini@redhat.com, eblake@redhat.com Subject: [Qemu-devel] [PATCH 11/11] Restart optimization on stage3 update version X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Juan Quintela Signed-off-by: Juan Quintela Signed-off-by: Juan Quintela > --- arch_init.c | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/arch_init.c b/arch_init.c index f484bd5..f555c27 100644 --- a/arch_init.c +++ b/arch_init.c @@ -279,7 +279,7 @@ static void save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset, static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, ram_addr_t current_addr, RAMBlock *block, - ram_addr_t offset, int cont) + ram_addr_t offset, int cont, bool last_stage) { int encoded_len = 0, bytes_sent = -1; XBZRLEHeader hdr = { @@ -289,8 +289,10 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, uint8_t *prev_cached_page; if (!cache_is_cached(XBZRLE.cache, current_addr)) { - cache_insert(XBZRLE.cache, current_addr, - g_memdup(current_data, TARGET_PAGE_SIZE)); + if (!last_stage) { + cache_insert(XBZRLE.cache, current_addr, + g_memdup(current_data, TARGET_PAGE_SIZE)); + } acct_info.xbzrle_cache_miss++; return -1; } @@ -317,7 +319,9 @@ 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 we cached we decode the encoded page on the cached data */ - memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE); + if (!last_stage) { + memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE); + } hdr.xh_len = encoded_len; hdr.xh_flags |= ENCODING_FLAG_XBZRLE; @@ -345,7 +349,7 @@ static ram_addr_t last_offset; * n: the amount of bytes written in other case */ -static int ram_save_block(QEMUFile *f) +static int ram_save_block(QEMUFile *f, bool last_stage) { RAMBlock *block = last_block; ram_addr_t offset = last_offset; @@ -376,8 +380,10 @@ static int ram_save_block(QEMUFile *f) } else if (migrate_use_xbzrle()) { current_addr = block->offset + offset; bytes_sent = save_xbzrle_page(f, p, current_addr, block, - offset, cont); - p = get_cached_data(XBZRLE.cache, current_addr); + offset, cont, last_stage); + if (!last_stage) { + p = get_cached_data(XBZRLE.cache, current_addr); + } } /* either we didn't send yet (we may have had XBZRLE overflow) */ @@ -549,7 +555,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) while ((ret = qemu_file_rate_limit(f)) == 0) { int bytes_sent; - bytes_sent = ram_save_block(f); + bytes_sent = ram_save_block(f, false); /* no more blocks to sent */ if (bytes_sent < 0) { break; @@ -611,7 +617,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) while (true) { int bytes_sent; - bytes_sent = ram_save_block(f); + bytes_sent = ram_save_block(f, true); /* no more blocks to sent */ if (bytes_sent < 0) { break;