From patchwork Fri Jun 22 13:46:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 166599 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 96A51B6EF1 for ; Fri, 22 Jun 2012 23:47:43 +1000 (EST) Received: from localhost ([::1]:38104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Si4D7-0005x4-HF for incoming@patchwork.ozlabs.org; Fri, 22 Jun 2012 09:47:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Si4C8-0003xR-7O for qemu-devel@nongnu.org; Fri, 22 Jun 2012 09:46:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Si4C0-0006GD-QJ for qemu-devel@nongnu.org; Fri, 22 Jun 2012 09:46:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Si4C0-0006Ft-IP for qemu-devel@nongnu.org; Fri, 22 Jun 2012 09:46:32 -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 q5MDkUo8027837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Jun 2012 09:46:30 -0400 Received: from trasno.mitica (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q5MDkKFM030931; Fri, 22 Jun 2012 09:46:29 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Jun 2012 15:46:16 +0200 Message-Id: <31388846c75d7136ebcdbd9150b399bcecf30322.1340371865.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: owasserm@redhat.com, vinodchegu@gmail.com Subject: [Qemu-devel] [PATCH 5/8] 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 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch_init.c b/arch_init.c index a9e8b74..424efe7 100644 --- a/arch_init.c +++ b/arch_init.c @@ -299,7 +299,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) { @@ -376,9 +375,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,