From mboxrd@z Thu Jan 1 00:00:00 1970 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) Sender: Paolo Bonzini From: Paolo Bonzini Date: Sat, 5 Mar 2011 18:14:14 +0100 Message-Id: <1299345255-577-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1299345255-577-1-git-send-email-pbonzini@redhat.com> References: <1299345255-577-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 2/3] Revert wrong fix for -icount in the iothread case List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: edgar.iglesias@gmail.com, mtosatti@redhat.com, jan.kiszka@web.de 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 } -- 1.7.4