From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43235 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNeUq-0006RT-4i for qemu-devel@nongnu.org; Tue, 30 Nov 2010 23:41:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PNRNv-0003F3-0U for qemu-devel@nongnu.org; Tue, 30 Nov 2010 09:40:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PNRNu-0002mR-KL for qemu-devel@nongnu.org; Tue, 30 Nov 2010 09:40:46 -0500 From: Juan Quintela In-Reply-To: <4CF45C5B.9080507@codemonkey.ws> (Anthony Liguori's message of "Mon, 29 Nov 2010 20:07:23 -0600") References: <4CF45C5B.9080507@codemonkey.ws> Date: Tue, 30 Nov 2010 15:40:34 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 08/10] Count nanoseconds with uint64_t not doubles List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org Anthony Liguori wrote: > On 11/23/2010 05:03 PM, Juan Quintela wrote: >> From: Juan Quintela >> >> Signed-off-by: Juan Quintela >> Signed-off-by: Juan Quintela >> > > Why? I needed the precision for the timestamp. Nanoseconds is an "integer" property, not a float value. And ferther more, until last line, we are using a variable named "bwidth" to measure times. Later, Juan. > Regards, > > Anthony Liguori > >> --- >> arch_init.c | 7 ++++--- >> 1 files changed, 4 insertions(+), 3 deletions(-) >> >> diff --git a/arch_init.c b/arch_init.c >> index 9e941a0..d32aaae 100644 >> --- a/arch_init.c >> +++ b/arch_init.c >> @@ -216,6 +216,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) >> { >> ram_addr_t addr; >> uint64_t bytes_transferred_last; >> + uint64_t t0; >> double bwidth = 0; >> >> if (stage< 0) { >> @@ -258,7 +259,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) >> } >> >> bytes_transferred_last = bytes_transferred; >> - bwidth = qemu_get_clock_ns(rt_clock); >> + t0 = qemu_get_clock_ns(rt_clock); >> >> while (!qemu_file_rate_limit(f)) { >> int bytes_sent; >> @@ -270,8 +271,8 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) >> } >> } >> >> - bwidth = qemu_get_clock_ns(rt_clock) - bwidth; >> - bwidth = (bytes_transferred - bytes_transferred_last) / bwidth; >> + t0 = qemu_get_clock_ns(rt_clock) - t0; >> + bwidth = (bytes_transferred - bytes_transferred_last) / t0; >> >> /* if we haven't transferred anything this round, force expected_time to a >> * a very high value, but without crashing */ >>