From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf8Gk-0000JW-Q6 for qemu-devel@nongnu.org; Thu, 14 Jun 2012 07:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sf8Gg-0005Jo-5H for qemu-devel@nongnu.org; Thu, 14 Jun 2012 07:31:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf8Gf-0005JW-Tg for qemu-devel@nongnu.org; Thu, 14 Jun 2012 07:31:14 -0400 Message-ID: <4FD9CB84.1010300@redhat.com> Date: Thu, 14 Jun 2012 14:31:16 +0300 From: Orit Wasserman MIME-Version: 1.0 References: <312d2b7b78326039b1554a9e2a4573c1f6c9d0c3.1337710679.git.quintela@redhat.com> In-Reply-To: <312d2b7b78326039b1554a9e2a4573c1f6c9d0c3.1337710679.git.quintela@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/7] Only calculate expected_time for stage 2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: chegu_vinod@hp.com, qemu-devel@nongnu.org On 05/22/2012 09:32 PM, Juan Quintela wrote: > 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 | 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, Reviewed-by: Orit Wasserman