From patchwork Fri Jan 18 11:53:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 213580 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 9605C2C007B for ; Fri, 18 Jan 2013 22:54:33 +1100 (EST) Received: from localhost ([::1]:48728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwAWk-0007Kh-CU for incoming@patchwork.ozlabs.org; Fri, 18 Jan 2013 06:54:30 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwAWG-00070u-Q8 for qemu-devel@nongnu.org; Fri, 18 Jan 2013 06:54:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TwAWE-0003ox-AA for qemu-devel@nongnu.org; Fri, 18 Jan 2013 06:54:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:10236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwAWE-0003om-26 for qemu-devel@nongnu.org; Fri, 18 Jan 2013 06:53:58 -0500 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 r0IBrvxV029293 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 18 Jan 2013 06:53:57 -0500 Received: from trasno.mitica (ovpn-113-25.phx2.redhat.com [10.3.113.25]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0IBrrUj002451; Fri, 18 Jan 2013 06:53:56 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 18 Jan 2013 12:53:51 +0100 Message-Id: <1358510033-17268-3-git-send-email-quintela@redhat.com> In-Reply-To: <1358510033-17268-1-git-send-email-quintela@redhat.com> References: <1358510033-17268-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/4] ram: remove xbrle last_stage optimization 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 We need to remove it to be able to return from complete to iterative phases of migration. Signed-off-by: Juan Quintela --- arch_init.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/arch_init.c b/arch_init.c index 2792b76..9f7d44d 100644 --- a/arch_init.c +++ b/arch_init.c @@ -286,16 +286,14 @@ static size_t 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, bool last_stage) + ram_addr_t offset, int cont) { int encoded_len = 0, bytes_sent = -1; uint8_t *prev_cached_page; if (!cache_is_cached(XBZRLE.cache, current_addr)) { - if (!last_stage) { - cache_insert(XBZRLE.cache, current_addr, - g_memdup(current_data, TARGET_PAGE_SIZE)); - } + cache_insert(XBZRLE.cache, current_addr, + g_memdup(current_data, TARGET_PAGE_SIZE)); acct_info.xbzrle_cache_miss++; return -1; } @@ -321,9 +319,7 @@ 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); - } + memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE); /* Send XBZRLE based compressed page */ bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_XBZRLE); @@ -426,7 +422,7 @@ static void migration_bitmap_sync(void) * 0 means no dirty pages */ -static int ram_save_block(QEMUFile *f, bool last_stage) +static int ram_save_block(QEMUFile *f) { RAMBlock *block = last_seen_block; ram_addr_t offset = last_offset; @@ -470,10 +466,8 @@ static int ram_save_block(QEMUFile *f, bool last_stage) } else if (migrate_use_xbzrle()) { current_addr = block->offset + offset; bytes_sent = save_xbzrle_page(f, p, current_addr, block, - offset, cont, last_stage); - if (!last_stage) { - p = get_cached_data(XBZRLE.cache, current_addr); - } + offset, cont); + p = get_cached_data(XBZRLE.cache, current_addr); } /* XBZRLE overflow or normal page */ @@ -621,7 +615,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque, uint64_t free_space) i = 0; /* We need space for at least one page and end of section marker */ while (free_space > MAX_PAGE_SIZE + 8) { - int bytes_sent = ram_save_block(f, false); + int bytes_sent = ram_save_block(f); /* no more blocks to sent */ if (bytes_sent == 0) { break; @@ -665,7 +659,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) while (true) { int bytes_sent; - bytes_sent = ram_save_block(f, true); + bytes_sent = ram_save_block(f); /* no more blocks to sent */ if (bytes_sent == 0) { break;