From patchwork Mon Dec 21 08:09:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 41520 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 A4DBCB6EFE for ; Mon, 21 Dec 2009 19:33:58 +1100 (EST) Received: from localhost ([127.0.0.1]:35070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMdiD-0008JW-Uv for incoming@patchwork.ozlabs.org; Mon, 21 Dec 2009 03:33:54 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NMdKn-0002hk-9K for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:42 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NMdKj-0002g5-1X for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:40 -0500 Received: from [199.232.76.173] (port=52810 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMdKh-0002g1-Iz for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19039) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NMdKh-0003nU-3T for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:35 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBL89Yu7029827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Dec 2009 03:09:34 -0500 Received: from localhost.localdomain (vpn2-10-119.ams2.redhat.com [10.36.10.119]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBL89V3M011460 for ; Mon, 21 Dec 2009 03:09:33 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 21 Dec 2009 09:09:13 +0100 Message-Id: <1261382970-23251-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1261382970-23251-1-git-send-email-pbonzini@redhat.com> References: <1261382970-23251-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 02/19] add qemu_icount_round 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 Signed-off-by: Paolo Bonzini --- vl.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/vl.c b/vl.c index e38cea7..97410ad 100644 --- a/vl.c +++ b/vl.c @@ -920,6 +920,11 @@ static void configure_icount(const char *option) qemu_get_clock(vm_clock) + get_ticks_per_sec() / 10); } +static int64_t qemu_icount_round(int64_t count) +{ + return (count + (1 << icount_time_shift) - 1) >> icount_time_shift; +} + static struct qemu_alarm_timer alarm_timers[] = { #ifndef _WIN32 #ifdef __linux__ @@ -4031,9 +4036,7 @@ static int qemu_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_next_deadline(); - count = (count + (1 << icount_time_shift) - 1) - >> icount_time_shift; + count = qemu_icount_round (qemu_next_deadline()); qemu_icount += count; decr = (count > 0xffff) ? 0xffff : count; count -= decr; @@ -4141,9 +4144,7 @@ static int qemu_calculate_timeout(void) if (add > 10000000) add = 10000000; delta += add; - add = (add + (1 << icount_time_shift) - 1) - >> icount_time_shift; - qemu_icount += add; + qemu_icount += qemu_icount_round (add); timeout = delta / 1000000; if (timeout < 0) timeout = 0;