From patchwork Tue May 22 18:32:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 160723 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 4C69BB6FA5 for ; Wed, 23 May 2012 05:07:59 +1000 (EST) Received: from localhost ([::1]:47877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWttX-0002cd-16 for incoming@patchwork.ozlabs.org; Tue, 22 May 2012 14:33:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWtsn-0000fR-W2 for qemu-devel@nongnu.org; Tue, 22 May 2012 14:32:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWtsm-00081C-6b for qemu-devel@nongnu.org; Tue, 22 May 2012 14:32:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWtsl-00080x-VL for qemu-devel@nongnu.org; Tue, 22 May 2012 14:32:32 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4MIWOge019615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 May 2012 14:32:24 -0400 Received: from trasno.mitica (ovpn-116-82.ams2.redhat.com [10.36.116.82]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4MIWDof012834; Tue, 22 May 2012 14:32:23 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 22 May 2012 20:32:12 +0200 Message-Id: <189d97ce396dd1b4e8b497fbd1b276086ac05cbc.1337710679.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: chegu_vinod@hp.com Subject: [Qemu-devel] [PATCH 6/7] Exit loop if we have been there too long 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 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. We want to be sure that we spent less than 50ms (half of buffered_file timer), if we spent more than 100ms, all the accounting got wrong. Signed-off-by: Juan Quintela --- arch_init.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/arch_init.c b/arch_init.c index 76a3d4e..2aa77ff 100644 --- a/arch_init.c +++ b/arch_init.c @@ -296,6 +296,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) uint64_t bytes_transferred_last; double bwidth = 0; int ret; + int i; if (stage < 0) { memory_global_dirty_log_stop(); @@ -335,6 +336,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) bytes_transferred_last = bytes_transferred; bwidth = qemu_get_clock_ns(rt_clock); + i = 0; while ((ret = qemu_file_rate_limit(f)) == 0) { int bytes_sent; @@ -343,6 +345,19 @@ int ram_save_live(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) - bwidth) / 1000000; + if (t1 > 50) { /* 50ms, half buffered_file limit */ + printf("big delay %ld milliseconds, %d iterations\n", t1, i); + break; + } + } + i++; } if (ret < 0) {