From patchwork Fri Feb 22 10:16:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 222502 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 823572C02B0 for ; Fri, 22 Feb 2013 21:17:48 +1100 (EST) Received: from localhost ([::1]:50096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8phK-0003yi-5P for incoming@patchwork.ozlabs.org; Fri, 22 Feb 2013 05:17:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8pgP-0002Ht-Qv for qemu-devel@nongnu.org; Fri, 22 Feb 2013 05:16:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8pgO-0004ir-0U for qemu-devel@nongnu.org; Fri, 22 Feb 2013 05:16:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8pgN-0004ij-Ng for qemu-devel@nongnu.org; Fri, 22 Feb 2013 05:16:47 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1MAGlUA004972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 22 Feb 2013 05:16:47 -0500 Received: from trasno.mitica (ovpn-113-94.phx2.redhat.com [10.3.113.94]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1MAGgjL012893; Fri, 22 Feb 2013 05:16:46 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2013 11:16:40 +0100 Message-Id: <1361528201-15422-4-git-send-email-quintela@redhat.com> In-Reply-To: <1361528201-15422-1-git-send-email-quintela@redhat.com> References: <1361528201-15422-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/4] migration: don't account sleep time for calculating bandwidth 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 While we are sleeping we are not sending, so we should not use that time to estimate our bandwidth. Signed-off-by: Juan Quintela Reviewed-by: Orit Wasserman --- migration.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/migration.c b/migration.c index b8e412f..6649e3a 100644 --- a/migration.c +++ b/migration.c @@ -658,6 +658,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; @@ -730,7 +731,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; @@ -739,11 +740,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) {