From patchwork Mon Dec 21 08:09:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 41531 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 2A256B6F0C for ; Mon, 21 Dec 2009 19:58:50 +1100 (EST) Received: from localhost ([127.0.0.1]:56636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMe6J-0004fk-Sg for incoming@patchwork.ozlabs.org; Mon, 21 Dec 2009 03:58:47 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NMdKw-0002mS-RS for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NMdKr-0002jB-GF for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:49 -0500 Received: from [199.232.76.173] (port=52821 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMdKq-0002it-KH for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43340) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NMdKq-0003os-45 for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:44 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBL89h8g024689 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Dec 2009 03:09:43 -0500 Received: from localhost.localdomain (vpn2-10-119.ams2.redhat.com [10.36.10.119]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBL89V3W011460 for ; Mon, 21 Dec 2009 03:09:42 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 21 Dec 2009 09:09:23 +0100 Message-Id: <1261382970-23251-13-git-send-email-pbonzini@redhat.com> In-Reply-To: <1261382970-23251-1-git-send-email-pbonzini@redhat.com> References: <1261382970-23251-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 12/19] new function qemu_icount_delta 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 Tweaking the rounding in qemu_next_deadline ensures that there's no change whatsoever. Signed-off-by: Paolo Bonzini --- vl.c | 27 ++++++++++++++++----------- 1 files changed, 16 insertions(+), 11 deletions(-) diff --git a/vl.c b/vl.c index 289aadc..9f363c8 100644 --- a/vl.c +++ b/vl.c @@ -525,6 +525,20 @@ static int64_t cpu_get_clock(void) } } +static int64_t qemu_icount_delta(void) +{ + if (!use_icount) { + return 5000 * (int64_t) 1000000; + } else if (use_icount == 1) { + /* When not using an adaptive execution frequency + we tend to get badly out of sync with real time, + so just delay for a reasonable amount of time. */ + return 0; + } else { + return cpu_get_icount() - cpu_get_clock(); + } +} + /* enable cpu_get_ticks() */ void cpu_enable_ticks(void) { @@ -3940,25 +3954,16 @@ static int qemu_calculate_timeout(void) timeout = 5000; else if (tcg_has_work()) timeout = 0; - else if (!use_icount) - timeout = 5000; else { /* XXX: use timeout computed from timers */ int64_t add; int64_t delta; /* Advance virtual time to the next event. */ - if (use_icount == 1) { - /* When not using an adaptive execution frequency - we tend to get badly out of sync with real time, - so just delay for a reasonable amount of time. */ - delta = 0; - } else { - delta = cpu_get_icount() - cpu_get_clock(); - } + delta = qemu_icount_delta(); if (delta > 0) { /* If virtual time is ahead of real time then just wait for IO. */ - timeout = (delta / 1000000) + 1; + timeout = (delta + 999999) / 1000000; } else { /* Wait for either IO to occur or the next timer event. */