From patchwork Fri Jun 29 16:44:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 168240 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 786CBB6FA7 for ; Sat, 30 Jun 2012 03:58:14 +1000 (EST) Received: from localhost ([::1]:56719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkeJm-0006tp-3d for incoming@patchwork.ozlabs.org; Fri, 29 Jun 2012 12:45:14 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkeJ3-0005cL-8g for qemu-devel@nongnu.org; Fri, 29 Jun 2012 12:44:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SkeIx-0005JE-0E for qemu-devel@nongnu.org; Fri, 29 Jun 2012 12:44:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20936) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkeIw-0005HF-OU for qemu-devel@nongnu.org; Fri, 29 Jun 2012 12:44:22 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5TGiLgY019389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 29 Jun 2012 12:44:21 -0400 Received: from trasno.mitica (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5TGi4Fp027488; Fri, 29 Jun 2012 12:44:20 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2012 18:44:01 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/13] Only calculate expected_time for stage 2 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 ram_save_remaining() is an expensive operation when there is a lot of memory. So we only call the function when we need it. Signed-off-by: Juan Quintela --- arch_init.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch_init.c b/arch_init.c index f5fd1f5..643b696 100644 --- a/arch_init.c +++ b/arch_init.c @@ -314,7 +314,6 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) ram_addr_t addr; uint64_t bytes_transferred_last; double bwidth = 0; - uint64_t expected_time = 0; int ret; if (stage < 0) { @@ -391,12 +390,16 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) qemu_put_be64(f, RAM_SAVE_FLAG_EOS); - expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; + if (stage == 2) { + uint64_t expected_time; + expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; - DPRINTF("ram_save_live: expected(" PRIu64 ") <= max(" PRIu64 ")?\n", - expected_time, migrate_max_downtime()); + DPRINTF("ram_save_live: expected(" PRIu64 ") <= max(" PRIu64 ")?\n", + expected_time, migrate_max_downtime()); - return (stage == 2) && (expected_time <= migrate_max_downtime()); + return expected_time <= migrate_max_downtime(); + } + return 0; } static inline void *host_from_stream_offset(QEMUFile *f,