From patchwork Wed Apr 13 08:03:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 90968 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5F354B6F80 for ; Wed, 13 Apr 2011 18:06:14 +1000 (EST) Received: from localhost ([::1]:48125 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9v5X-0007d0-QM for incoming@patchwork.ozlabs.org; Wed, 13 Apr 2011 04:06:11 -0400 Received: from eggs.gnu.org ([140.186.70.92]:49474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9v3l-0004mM-6k for qemu-devel@nongnu.org; Wed, 13 Apr 2011 04:04:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q9v3g-0005NT-78 for qemu-devel@nongnu.org; Wed, 13 Apr 2011 04:04:21 -0400 Received: from mail-gw0-f45.google.com ([74.125.83.45]:34037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9v3g-0005NO-2t for qemu-devel@nongnu.org; Wed, 13 Apr 2011 04:04:16 -0400 Received: by gwb19 with SMTP id 19so202660gwb.4 for ; Wed, 13 Apr 2011 01:04:15 -0700 (PDT) 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=H6PJeeagcysRFUBGyPH6I0742J1GUf/1mInh0L/MUmk=; b=CdgMiI1rGL7z3Z2nuxKy4WuICdhrdrdZ2i7pLQ7mjZv08wgSqENWDTcurTzR29NOYl 5YJ5g3B3vScNUFv04xcgBb44/YCWXshu9t/oNHMwKJ3kjGa+pErHKAFQexMp+sPcoiGE nleG/goX82r7FX/qEIf1Dhf2yANF3PHzG8TDs= 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=UCVOYFgS11o9S2AsjW8F6oas/NzoP/aVfB5ng11jugRJCEOcY1bNBvprvJuBq08wP7 xsKsMIDK0dPgQgjIULcoDqlTrPPy6RpkDVsyUzmf0+OKNEssHxQo5T1sHRLuTL8q6eEH pClE68TgrQyJljsACKHRUokR4Jsuamg61XNN0= Received: by 10.90.250.8 with SMTP id x8mr241112agh.164.1302681855446; Wed, 13 Apr 2011 01:04:15 -0700 (PDT) Received: from localhost.localdomain (93-34-184-88.ip51.fastwebnet.it [93.34.184.88]) by mx.google.com with ESMTPS id w6sm371575anf.32.2011.04.13.01.04.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Apr 2011 01:04:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 13 Apr 2011 10:03:45 +0200 Message-Id: <1302681826-10236-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1302681826-10236-1-git-send-email-pbonzini@redhat.com> References: <1302681826-10236-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.83.45 Cc: edgar.iglesias@gmail.com Subject: [Qemu-devel] [PATCH v4 3/4] Revert wrong fixes for -icount in the iothread case 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 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 Tested-by: Edgar E. Iglesias --- qemu-timer.c | 66 +++++++++++++++++++++++++++++++-------------------------- 1 files changed, 36 insertions(+), 30 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 4959688..7998f37 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) @@ -1147,39 +1151,41 @@ 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 }