From patchwork Sat Mar 5 17:14:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 85539 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 521631007DB for ; Sun, 6 Mar 2011 04:22:21 +1100 (EST) Received: from localhost ([127.0.0.1]:43458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvvBK-0003sb-Kz for incoming@patchwork.ozlabs.org; Sat, 05 Mar 2011 12:22:18 -0500 Received: from [140.186.70.92] (port=46696 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pvv3k-00081o-HF for qemu-devel@nongnu.org; Sat, 05 Mar 2011 12:14:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pvv3j-0004Sv-AE for qemu-devel@nongnu.org; Sat, 05 Mar 2011 12:14:28 -0500 Received: from mail-qw0-f45.google.com ([209.85.216.45]:51587) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pvv3j-0004RM-7a for qemu-devel@nongnu.org; Sat, 05 Mar 2011 12:14:27 -0500 Received: by mail-qw0-f45.google.com with SMTP id 8so2752140qwj.4 for ; Sat, 05 Mar 2011 09:14:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references; bh=/eLQ6hhlEmbTFdML9oiYFbUMy9Or6CqNPfgQkIIWc9s=; b=m/WaMAUerLOSEXwAOQ7QdznxE54XhWdINSEfzs/2H7cE+PZaMqfwHafSXl2KfmIglU QMecIjiL0IYOF7pvZ9c9IPFm05GvjZQnzgtQgeLnAzdbhKwYlQNXMK2rsJ3jOl7HYpmy JMed2IgqIsMrlTO+IL5QDJJmR3vVr44Rmfse4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=pCWLzJWcZPIFIOljamjHZMLt0/1CMZd/5G7dmURaU++ITQc8aJ+8GWLlw6Rne6m+yd YuE6+cYLieu2ZdKOxKeOyex3amG7JnxvBnhSxdn2u7F8pYx2rEFKcLJ6bzTUV/4uUqHI MdXcN64Mk25t4otJ7rN2lclVAlyJTrMZ0Q7Ak= Received: by 10.229.77.142 with SMTP id g14mr1617920qck.55.1299345267040; Sat, 05 Mar 2011 09:14:27 -0800 (PST) Received: from localhost.localdomain (93-34-197-200.ip51.fastwebnet.it [93.34.197.200]) by mx.google.com with ESMTPS id l17sm488500qck.8.2011.03.05.09.14.25 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 05 Mar 2011 09:14:26 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 5 Mar 2011 18:14:14 +0100 Message-Id: <1299345255-577-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1299345255-577-1-git-send-email-pbonzini@redhat.com> References: <1299345255-577-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.216.45 Cc: edgar.iglesias@gmail.com, mtosatti@redhat.com, jan.kiszka@web.de Subject: [Qemu-devel] [PATCH 2/3] Revert wrong fix for -icount in the iothread case 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 This reverts commits 225d02cd and c9f7383c. While some parts of the latter could be saved, I preferred a smooth, complete revert. Signed-off-by: Paolo Bonzini --- qemu-timer.c | 66 +++++++++++++++++++++++++++++++-------------------------- 1 files changed, 36 insertions(+), 30 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 06fa507..4499e0c 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -110,9 +110,12 @@ static int64_t cpu_get_clock(void) } } +#ifndef CONFIG_IOTHREAD static int64_t qemu_icount_delta(void) { - if (use_icount == 1) { + 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. */ @@ -121,6 +124,7 @@ static int64_t qemu_icount_delta(void) return cpu_get_icount() - cpu_get_clock(); } } +#endif /* enable cpu_get_ticks() */ void cpu_enable_ticks(void) @@ -1069,39 +1073,43 @@ void quit_timers(void) int qemu_calculate_timeout(void) { +#ifndef CONFIG_IOTHREAD int timeout; - int64_t add; - int64_t delta; - /* When using icount, making forward progress with qemu_icount when the - guest CPU is idle is critical. We only use the static io-thread timeout - for non icount runs. */ - if (!use_icount || !vm_running) { - return 5000; - } - - /* Advance virtual time to the next event. */ - delta = qemu_icount_delta(); - if (delta > 0) { - /* If virtual time is ahead of real time then just - wait for IO. */ - timeout = (delta + 999999) / 1000000; - } else { - /* Wait for either IO to occur or the next - timer event. */ - add = qemu_next_deadline(); - /* We advance the timer before checking for IO. - Limit the amount we advance so that early IO - activity won't get the guest too far ahead. */ - if (add > 10000000) - add = 10000000; - delta += add; - qemu_icount += qemu_icount_round (add); - timeout = delta / 1000000; - if (timeout < 0) - timeout = 0; + if (!vm_running) { + timeout = 5000; + } else { + /* XXX: use timeout computed from timers */ + int64_t add; + int64_t delta; + /* Advance virtual time to the next event. */ + delta = qemu_icount_delta(); + if (delta > 0) { + /* If virtual time is ahead of real time then just + wait for IO. */ + timeout = (delta + 999999) / 1000000; + } else { + /* Wait for either IO to occur or the next + timer event. */ + add = qemu_next_deadline(); + /* We advance the timer before checking for IO. + Limit the amount we advance so that early IO + activity won't get the guest too far ahead. */ + if (add > 10000000) { + add = 10000000; + } + delta += add; + qemu_icount += qemu_icount_round(add); + timeout = delta / 1000000; + if (timeout < 0) { + timeout = 0; + } + } } return timeout; +#else /* CONFIG_IOTHREAD */ + return 1000; +#endif }