From patchwork Wed Mar 10 10:38:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 47243 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 575ACB7CE6 for ; Wed, 10 Mar 2010 22:37:51 +1100 (EST) Received: from localhost ([127.0.0.1]:51301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpKEW-0004xT-9f for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2010 06:37:48 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NpJJr-0008Li-2M for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:39:15 -0500 Received: from [199.232.76.173] (port=52790 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpJJp-0008KQ-RW for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:39:13 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NpJJo-0004vB-UY for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:39:13 -0500 Received: from ey-out-1920.google.com ([74.125.78.147]:61296) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NpJJo-0004sn-CS for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:39:12 -0500 Received: by ey-out-1920.google.com with SMTP id 5so4373191eyb.14 for ; Wed, 10 Mar 2010 02:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :message-id:x-mailer:in-reply-to:references; bh=7YfQ3dnc6j1rY3KwOc1aTr6NqSCfnPUBI0fuuzFQfSM=; b=qt3VsPmk5uXWuBeeskiIuFwRqobL1XT/2XKq79N1Q6a+68zCOCuxK1cGesmYdRKPoC Hw0NXjvV/6ErThVQ6AlsalScIppdgXRUQbHwGE742M/ftFtGQEmO8PMKwf6E9vrKGuCB dJN2ux/dQNO7oXe/rCMDRwGjp77RAYv+1Mos4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; b=ZcXUPUB6EkVPAYrcJODqUQxGXYadW3J4ZyfhnF8eajblV4yfpTGJtc1pcQc7IqRX9m IB44h8Y4hGUTH9re5wmHNA7iXqWw4UyLwj8JaFIUHlE7eJxiFFkqwdThm6ZUVuswca7j G5Lbaz1+m01hde/hJdPGW5+j0qYTyX8O6KO7o= Received: by 10.213.1.132 with SMTP id 4mr4823098ebf.11.1268217551979; Wed, 10 Mar 2010 02:39:11 -0800 (PST) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com [209.132.186.34]) by mx.google.com with ESMTPS id 14sm3836002ewy.2.2010.03.10.02.39.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Mar 2010 02:39:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 10 Mar 2010 11:38:51 +0100 Message-Id: <1268217535-26554-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1268217535-26554-1-git-send-email-pbonzini@redhat.com> References: <1268217535-26554-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 14/18] 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 | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-) diff --git a/vl.c b/vl.c index 18bd2ee..d10319f 100644 --- a/vl.c +++ b/vl.c @@ -548,6 +548,22 @@ static int64_t cpu_get_clock(void) } } +#ifndef CONFIG_IOTHREAD +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(); + } +} +#endif + /* enable cpu_get_ticks() */ void cpu_enable_ticks(void) { @@ -4052,25 +4068,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. */