From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1Fnk-0005Ua-Vx for qemu-devel@nongnu.org; Fri, 01 Feb 2013 07:33:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1Fnj-0000O1-Tm for qemu-devel@nongnu.org; Fri, 01 Feb 2013 07:33:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1Fnj-0000Nt-Kn for qemu-devel@nongnu.org; Fri, 01 Feb 2013 07:33:03 -0500 From: Juan Quintela Date: Fri, 1 Feb 2013 13:32:55 +0100 Message-Id: <1359721976-19238-4-git-send-email-quintela@redhat.com> In-Reply-To: <1359721976-19238-1-git-send-email-quintela@redhat.com> References: <1359721976-19238-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 3/4] migration: don't account sleep time for calculating bandwidth List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Qemu Devel , Anthony Liguori While we are sleeping we are not sending, so we should not use that time to estimate our bandwidth. Signed-off-by: Juan Quintela --- migration.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/migration.c b/migration.c index 67abd12..64e75ca 100644 --- a/migration.c +++ b/migration.c @@ -666,6 +666,7 @@ static void *buffered_file_thread(void *opaque) { MigrationState *s = opaque; int64_t initial_time = qemu_get_clock_ms(rt_clock); + int64_t sleep_time = 0; int64_t max_size = 0; bool last_round = false; int ret; @@ -738,7 +739,7 @@ static void *buffered_file_thread(void *opaque) current_time = qemu_get_clock_ms(rt_clock); if (current_time >= initial_time + BUFFER_DELAY) { uint64_t transferred_bytes = s->bytes_xfer; - uint64_t time_spent = current_time - initial_time; + uint64_t time_spent = current_time - initial_time - sleep_time; double bandwidth = transferred_bytes / time_spent; max_size = bandwidth * migrate_max_downtime() / 1000000; @@ -747,11 +748,13 @@ static void *buffered_file_thread(void *opaque) transferred_bytes, time_spent, bandwidth, max_size); s->bytes_xfer = 0; + sleep_time = 0; initial_time = current_time; } if (!last_round && (s->bytes_xfer >= s->xfer_limit)) { /* usleep expects microseconds */ g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); + sleep_time += qemu_get_clock_ms(rt_clock) - current_time; } ret = buffered_flush(s); if (ret < 0) { -- 1.8.1