From patchwork Wed Apr 13 08:03:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 90966 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 553AFB6F7D for ; Wed, 13 Apr 2011 18:05:03 +1000 (EST) Received: from localhost ([::1]:48101 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9v4O-0005Nk-4B for incoming@patchwork.ozlabs.org; Wed, 13 Apr 2011 04:05:00 -0400 Received: from eggs.gnu.org ([140.186.70.92]:49484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9v3m-0004od-5F for qemu-devel@nongnu.org; Wed, 13 Apr 2011 04:04:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q9v3i-0005Nd-5r for qemu-devel@nongnu.org; Wed, 13 Apr 2011 04:04:22 -0400 Received: from mail-yi0-f45.google.com ([209.85.218.45]:56141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9v3i-0005NA-16 for qemu-devel@nongnu.org; Wed, 13 Apr 2011 04:04:18 -0400 Received: by mail-yi0-f45.google.com with SMTP id 19so201964yib.4 for ; Wed, 13 Apr 2011 01:04:17 -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=EwJQ4WnCJI+EArYRDNJIg7NJXk3QbJELd0tJoBPS41g=; b=N2zx6/sUN6jJiMf0JYQezaxbsz8HTL6SSAm8cM4OUKSTLnKULDvH+0jskyaZD4/5dM tyPdDKYTak0ND0SpnrNzhGhJS4S20ccbGmfZirAxX9OclL5ex42MFWD6RFcJSPPHHkle XmueSNG1GNJAAOvnIbci6d0F0w0Qm8I3igyqw= 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=DmBYJ88GY9tXEwbvGzIFaK6JUU/5dV3cxhmB0JCWreedhGPavneBG7otEGGyKSttnH apVuw34C6NaQpa3qmGq3AIfQCGSEviDguqZxU4+0/h4Fwiy6XDDUQK8LwnpQqxcZ9mcJ 6n3sz7Asro9goxrU7xPNDSR6UreN645FHlEho= Received: by 10.146.98.3 with SMTP id v3mr6641220yab.36.1302681857845; Wed, 13 Apr 2011 01:04:17 -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.15 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Apr 2011 01:04:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 13 Apr 2011 10:03:46 +0200 Message-Id: <1302681826-10236-5-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: 209.85.218.45 Cc: edgar.iglesias@gmail.com Subject: [Qemu-devel] [PATCH v4 4/4] qemu_next_deadline should not consider host-time timers 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 It is purely for icount-based virtual timers. And now that we got the code right, rename the function to clarify the intended scope. Signed-off-by: Paolo Bonzini Tested-by: Edgar E. Iglesias --- cpus.c | 4 ++-- qemu-timer.c | 13 ++++--------- qemu-timer.h | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cpus.c b/cpus.c index 6a50199..1fc34b7 100644 --- a/cpus.c +++ b/cpus.c @@ -833,7 +833,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) while (1) { cpu_exec_all(); - if (use_icount && qemu_next_deadline() <= 0) { + if (use_icount && qemu_next_icount_deadline() <= 0) { qemu_notify_event(); } qemu_tcg_wait_io_event(); @@ -1050,7 +1050,7 @@ static int tcg_cpu_exec(CPUState *env) qemu_icount -= (env->icount_decr.u16.low + env->icount_extra); env->icount_decr.u16.low = 0; env->icount_extra = 0; - count = qemu_icount_round (qemu_next_deadline()); + count = qemu_icount_round(qemu_next_icount_deadline()); qemu_icount += count; decr = (count > 0xffff) ? 0xffff : count; count -= decr; diff --git a/qemu-timer.c b/qemu-timer.c index 7998f37..b8c0c88 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -452,7 +452,7 @@ void qemu_clock_warp(QEMUClock *clock) } vm_clock_warp_start = qemu_get_clock_ns(rt_clock); - deadline = qemu_next_deadline(); + deadline = qemu_next_icount_deadline(); if (deadline > 0) { /* * Ensure the vm_clock proceeds even when the virtual CPU goes to @@ -765,21 +765,16 @@ static void host_alarm_handler(int host_signum) } } -int64_t qemu_next_deadline(void) +int64_t qemu_next_icount_deadline(void) { /* To avoid problems with overflow limit this to 2^32. */ int64_t delta = INT32_MAX; + assert(use_icount); if (active_timers[QEMU_CLOCK_VIRTUAL]) { delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time - qemu_get_clock_ns(vm_clock); } - if (active_timers[QEMU_CLOCK_HOST]) { - int64_t hdelta = active_timers[QEMU_CLOCK_HOST]->expire_time - - qemu_get_clock_ns(host_clock); - if (hdelta < delta) - delta = hdelta; - } if (delta < 0) delta = 0; @@ -1169,7 +1164,7 @@ int qemu_calculate_timeout(void) } else { /* Wait for either IO to occur or the next timer event. */ - add = qemu_next_deadline(); + add = qemu_next_icount_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. */ diff --git a/qemu-timer.h b/qemu-timer.h index c01bcab..3a9228f 100644 --- a/qemu-timer.h +++ b/qemu-timer.h @@ -51,7 +51,7 @@ int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); void qemu_run_all_timers(void); int qemu_alarm_pending(void); -int64_t qemu_next_deadline(void); +int64_t qemu_next_icount_deadline(void); void configure_alarms(char const *opt); void configure_icount(const char *option); int qemu_calculate_timeout(void);