From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTSxl-0004vI-91 for qemu-devel@nongnu.org; Tue, 08 Oct 2013 04:48:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTSxc-0003bF-Sb for qemu-devel@nongnu.org; Tue, 08 Oct 2013 04:48:17 -0400 Received: from mail-ea0-x22d.google.com ([2a00:1450:4013:c01::22d]:50656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTSxc-0003b0-LN for qemu-devel@nongnu.org; Tue, 08 Oct 2013 04:48:08 -0400 Received: by mail-ea0-f173.google.com with SMTP id g10so3814365eak.32 for ; Tue, 08 Oct 2013 01:48:07 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 8 Oct 2013 10:47:33 +0200 Message-Id: <1381222058-16701-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1381222058-16701-1-git-send-email-pbonzini@redhat.com> References: <1381222058-16701-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 3/8] timers: use cpu_get_icount() directly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex@alex.org.uk This will help later when we will have to place these calls in a critical section, and thus call a version of cpu_get_icount() that does not take the lock. Signed-off-by: Paolo Bonzini --- cpus.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cpus.c b/cpus.c index 870a832..f87ff6f 100644 --- a/cpus.c +++ b/cpus.c @@ -224,12 +224,15 @@ static void icount_adjust(void) int64_t cur_icount; int64_t delta; static int64_t last_delta; + /* If the VM is not running, then do nothing. */ if (!runstate_is_running()) { return; } + cur_time = cpu_get_clock(); - cur_icount = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + cur_icount = cpu_get_icount(); + delta = cur_icount - cur_time; /* FIXME: This is a very crude algorithm, somewhat prone to oscillation. */ if (delta > 0 @@ -285,7 +288,7 @@ static void icount_warp_rt(void *opaque) * far ahead of real time. */ int64_t cur_time = cpu_get_clock(); - int64_t cur_icount = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + int64_t cur_icount = cpu_get_icount(); int64_t delta = cur_time - cur_icount; qemu_icount_bias += MIN(warp_delta, delta); } -- 1.8.3.1