Received: from eggs.gnu.org ([2001:4830:134:3::10]:41430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWppN-000783-Om for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWppH-0000on-AD for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:49:33 -0400 Received: from mail-ee0-x230.google.com ([2a00:1450:4013:c00::230]:42188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWppH-0000ob-2Y for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:49:27 -0400 Received: by mail-ee0-f48.google.com with SMTP id e50so241655eek.35 for ; Thu, 17 Oct 2013 08:49:26 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 17 Oct 2013 17:48:50 +0200 Message-Id: <1382024935-28297-13-git-send-email-pbonzini@redhat.com> In-Reply-To: <1382024935-28297-1-git-send-email-pbonzini@redhat.com> References: <1382024935-28297-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 12/17] icount: use cpu_get_icount() directly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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. Reviewed-by: Alex Bligh Signed-off-by: Paolo Bonzini --- cpus.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index f075335..a2d09f3 100644 --- a/cpus.c +++ b/cpus.c @@ -236,12 +236,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 @@ -297,7 +300,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