From patchwork Tue Nov 23 23:03:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 72778 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6CA5AB6EF2 for ; Wed, 24 Nov 2010 10:18:23 +1100 (EST) Received: from localhost ([127.0.0.1]:39662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PL27w-0000sn-GR for incoming@patchwork.ozlabs.org; Tue, 23 Nov 2010 18:18:20 -0500 Received: from [140.186.70.92] (port=48839 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PL1tq-0001NJ-MZ for qemu-devel@nongnu.org; Tue, 23 Nov 2010 18:04:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PL1tY-0000tr-R4 for qemu-devel@nongnu.org; Tue, 23 Nov 2010 18:03:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PL1tY-0000tf-KE for qemu-devel@nongnu.org; Tue, 23 Nov 2010 18:03:28 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oANN3RwG020254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 23 Nov 2010 18:03:27 -0500 Received: from trasno.mitica (ovpn-113-23.phx2.redhat.com [10.3.113.23]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oANN3D5d025161; Tue, 23 Nov 2010 18:03:26 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 24 Nov 2010 00:03:06 +0100 Message-Id: <9b23b9b4cee242591bdb356c838a9cfb9af033c1.1290552026.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Juan Quintela Subject: [Qemu-devel] [PATCH 09/10] Exit loop if we have been there too long X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Juan Quintela cheking each 64 pages is a random magic number as good as any other. We don't want to test too many times, but on the other hand, qemu_get_clock_ns() is not so expensive either. Signed-off-by: Juan Quintela Signed-off-by: Juan Quintela --- arch_init.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/arch_init.c b/arch_init.c index d32aaae..b463798 100644 --- a/arch_init.c +++ b/arch_init.c @@ -40,6 +40,7 @@ #include "net.h" #include "gdbstub.h" #include "hw/smbios.h" +#include "buffered_file.h" #ifdef TARGET_SPARC int graphic_width = 1024; @@ -218,6 +219,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) uint64_t bytes_transferred_last; uint64_t t0; double bwidth = 0; + int i; if (stage < 0) { cpu_physical_memory_set_dirty_tracking(0); @@ -261,6 +263,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) bytes_transferred_last = bytes_transferred; t0 = qemu_get_clock_ns(rt_clock); + i = 0; while (!qemu_file_rate_limit(f)) { int bytes_sent; @@ -269,6 +272,19 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) if (bytes_sent == 0) { /* no more blocks */ break; } + /* we want to check in the 1st loop, just in case it was the 1st time + and we had to sync the dirty bitmap. + qemu_get_clock_ns() is a bit expensive, so we only check each some + iterations + */ + if ((i & 63) == 0) { + uint64_t t1 = (qemu_get_clock_ns(rt_clock) - t0) / 1000000; + if (t1 > buffered_file_interval/2) { + printf("big delay %ld milliseconds, %d iterations\n", t1, i); + break; + } + } + i++; } t0 = qemu_get_clock_ns(rt_clock) - t0;