From patchwork Sat Jan 29 11:00:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 80937 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 CC7E4B70F4 for ; Sat, 29 Jan 2011 22:03:03 +1100 (EST) Received: from localhost ([127.0.0.1]:50281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pj8Yr-0006bT-Mj for incoming@patchwork.ozlabs.org; Sat, 29 Jan 2011 06:01:45 -0500 Received: from [140.186.70.92] (port=49250 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pj8Y6-0006Yn-6e for qemu-devel@nongnu.org; Sat, 29 Jan 2011 06:00:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pj8Y5-00023S-4u for qemu-devel@nongnu.org; Sat, 29 Jan 2011 06:00:58 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]:35446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pj8Y5-000237-0a for qemu-devel@nongnu.org; Sat, 29 Jan 2011 06:00:57 -0500 Received: by wyg36 with SMTP id 36so4149534wyg.4 for ; Sat, 29 Jan 2011 03:00:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:subject:date:message-id:x-mailer :in-reply-to:references; bh=Znrw3I/TpYr0H6J1MmV4vGcApmgx2QaZpvip2QMEIW4=; b=w5A7qiQPcdHPBTxh/L4a+murDV4EMg/CgETPneevqehzKQQF+69H2S2P7y8mzvf0Cz Dm/tvLT/NjLgW0Dqwi4IR0OjPGY9XALMFN0mrb1fCl1eZl6mGZvb9VLIhhsfNbJk7oqk YrHWUSFpBGOTn51Fh3ZMqeGb/3qLOf+66sWzs= 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=CDamlEmVpZGtJ6MV+zyUSYP/Wo+C5L1k5GoGh/lE4Ww/uJrqTnqZ8Qpfex7ZMEYVJc eoC79My65kNMr8oA3RkNjACmtPUf4a7Sn7SsNur6YkOG7+Apwucyzt864XDjHcO50Zwu oHWHv4c5pcWBIIXnhmD+WO9q433lMe3gU0pBY= Received: by 10.216.153.147 with SMTP id f19mr8888509wek.40.1296298856053; Sat, 29 Jan 2011 03:00:56 -0800 (PST) Received: from localhost.localdomain (93-34-149-100.ip50.fastwebnet.it [93.34.149.100]) by mx.google.com with ESMTPS id c54sm9561860wer.30.2011.01.29.03.00.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 29 Jan 2011 03:00:55 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 29 Jan 2011 12:00:48 +0100 Message-Id: <1296298848-3080-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1296298848-3080-1-git-send-email-pbonzini@redhat.com> References: <1296298848-3080-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.82.173 Subject: [Qemu-devel] [PATCH 2/2] Unify alarm deadline computation 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 Now that qemu_next_deadline_dyntick uses the correct formula, we can simplify the code in host_alarm_handler and eliminate useless duplication. Also, qemu_next_deadline_dyntick is always used in signed arithmetic, so change its type. Signed-off-by: Paolo Bonzini --- qemu-timer.c | 28 +++++++++++----------------- roms/vgabios | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 174fd0c..1842d7a 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -635,6 +635,8 @@ void qemu_run_all_timers(void) qemu_run_timers(host_clock); } +static int64_t qemu_next_alarm_deadline(void); + #ifdef _WIN32 static void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, @@ -677,14 +679,7 @@ static void host_alarm_handler(int host_signum) } #endif if (alarm_has_dynticks(t) || - (!use_icount && - qemu_timer_expired(active_timers[QEMU_CLOCK_VIRTUAL], - qemu_get_clock(vm_clock))) || - qemu_timer_expired(active_timers[QEMU_CLOCK_REALTIME], - qemu_get_clock(rt_clock)) || - qemu_timer_expired(active_timers[QEMU_CLOCK_HOST], - qemu_get_clock(host_clock))) { - + qemu_next_alarm_deadline () <= 0) { t->expired = alarm_has_dynticks(t); t->pending = 1; qemu_notify_event(); @@ -715,11 +710,7 @@ int64_t qemu_next_deadline(void) #ifndef _WIN32 -#if defined(__linux__) - -#define RTC_FREQ 1024 - -static uint64_t qemu_next_deadline_dyntick(void) +static int64_t qemu_next_alarm_deadline(void) { int64_t delta; int64_t rtdelta; @@ -743,12 +734,13 @@ static uint64_t qemu_next_deadline_dyntick(void) delta = rtdelta; } - if (delta < MIN_TIMER_REARM_US) - delta = MIN_TIMER_REARM_US; - return delta; } +#if defined(__linux__) + +#define RTC_FREQ 1024 + static void enable_sigio_timer(int fd) { struct sigaction act; @@ -903,7 +895,9 @@ static void dynticks_rearm_timer(struct qemu_alarm_timer *t) !active_timers[QEMU_CLOCK_HOST]) return; - nearest_delta_us = qemu_next_deadline_dyntick(); + nearest_delta_us = qemu_next_alarm_deadline(); + if (nearest_delta_us < MIN_TIMER_REARM_US) + nearest_delta_us = MIN_TIMER_REARM_US; /* check whether a timer is already running */ if (timer_gettime(host_timer, &timeout)) {