From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpaEh-0000Gk-4j for qemu-devel@nongnu.org; Fri, 13 Jul 2012 03:24:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpaEc-0004To-VI for qemu-devel@nongnu.org; Fri, 13 Jul 2012 03:24:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpaEc-0004Te-LU for qemu-devel@nongnu.org; Fri, 13 Jul 2012 03:24:18 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6D7OImF017775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Jul 2012 03:24:18 -0400 From: Juan Quintela Date: Fri, 13 Jul 2012 09:23:44 +0200 Message-Id: <1342164224-32709-23-git-send-email-quintela@redhat.com> In-Reply-To: <1342164224-32709-1-git-send-email-quintela@redhat.com> References: <1342164224-32709-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 22/22] ram: save live optimization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Optimize stage3 (complete), to use the page cached if it is there, but not update the cache with new pages (they will never be reused). Signed-off-by: Juan Quintela --- arch_init.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch_init.c b/arch_init.c index ab3fb2c..de2d801 100644 --- a/arch_init.c +++ b/arch_init.c @@ -276,7 +276,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, ret = -1; XBZRLEHeader hdr = { @@ -341,7 +341,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; @@ -372,8 +372,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 ((bytes_sent != -1) || !last_stage) { + p = get_cached_data(XBZRLE.cache, current_addr); + } } /* either we didn't send yet (we may have had XBZRLE overflow) */ @@ -543,7 +545,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; @@ -605,7 +607,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; -- 1.7.10.4