From patchwork Tue May 22 18:32:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 160722 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 238EEB6FA5 for ; Wed, 23 May 2012 05:03:25 +1000 (EST) Received: from localhost ([::1]:47841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWttT-0002bl-Vs for incoming@patchwork.ozlabs.org; Tue, 22 May 2012 14:33:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWtsn-0000e2-I7 for qemu-devel@nongnu.org; Tue, 22 May 2012 14:32:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWtsk-00080z-Tm for qemu-devel@nongnu.org; Tue, 22 May 2012 14:32:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWtsk-00080Y-Lz for qemu-devel@nongnu.org; Tue, 22 May 2012 14:32:30 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4MIWNtW026628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 May 2012 14:32:23 -0400 Received: from trasno.mitica (ovpn-116-82.ams2.redhat.com [10.36.116.82]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4MIWDoe012834; Tue, 22 May 2012 14:32:22 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 22 May 2012 20:32:11 +0200 Message-Id: <312d2b7b78326039b1554a9e2a4573c1f6c9d0c3.1337710679.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: chegu_vinod@hp.com Subject: [Qemu-devel] [PATCH 5/7] 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 Reviewed-by: Orit Wasserman --- arch_init.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch_init.c b/arch_init.c index 988adca..76a3d4e 100644 --- a/arch_init.c +++ b/arch_init.c @@ -295,7 +295,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) { @@ -372,9 +371,12 @@ 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; - - return (stage == 2) && (expected_time <= migrate_max_downtime()); + if (stage == 2) { + uint64_t expected_time; + expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; + return expected_time <= migrate_max_downtime(); + } + return 0; } static inline void *host_from_stream_offset(QEMUFile *f,