From patchwork Tue Oct 8 08:47:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 281364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B74442C0098 for ; Tue, 8 Oct 2013 19:50:27 +1100 (EST) Received: from localhost ([::1]:35312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTSzp-00088c-SK for incoming@patchwork.ozlabs.org; Tue, 08 Oct 2013 04:50:25 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PxPZn8gnkjFDuSiZvXeRDk9wfj0IcljRagznhTh+Zmo=; b=FeROGulUgjqgNKNzq9oklyAS1uE46XjK+PZdQ6IWOPaftPgGwk3hFCFGZpzXwixUKh GxTAWj5/TqLKrTQb9PBSTVPsrwtIOFIH4cTHJXByBr65Eumgw5uJv0iRzstqVwUSTJIO wu14ixxqJXwhffkRqsaDrBz4pvUgsTqMYsU8mW46C2Zk2uH8fbg65p+M3hpXRVYAm7ZG cty3F2m3Sy013esGS9O62R4cyjoNOEDwoY7aQsSsaWzoQkSslGeWkAIWm81yx6buOC+l hT1sZV2BJDuW5p5bvK8B+DuZbD3hP+a/bxuUnTaByvrUD9lhwx0mdWKeUmZH2jpqLoH+ CcWw== X-Received: by 10.15.99.205 with SMTP id bl53mr707973eeb.82.1381222087759; Tue, 08 Oct 2013 01:48:07 -0700 (PDT) Received: from localhost.localdomain (net-2-39-10-130.cust.dsl.vodafone.it. [2.39.10.130]) by mx.google.com with ESMTPSA id m54sm73201892eex.2.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 08 Oct 2013 01:48:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 8 Oct 2013 10:47:33 +0200 Message-Id: <1381222058-16701-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1381222058-16701-1-git-send-email-pbonzini@redhat.com> References: <1381222058-16701-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22d Cc: alex@alex.org.uk Subject: [Qemu-devel] [PATCH 3/8] timers: use cpu_get_icount() directly 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 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 Reviewed-By: Alex Bligh --- 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); }