From patchwork Wed Apr 5 13:25:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 96858 Delivered-To: patch@linaro.org Received: by 10.182.246.10 with SMTP id xs10csp261870obc; Wed, 5 Apr 2017 06:33:09 -0700 (PDT) X-Received: by 10.55.31.156 with SMTP id n28mr2427807qkh.321.1491399189024; Wed, 05 Apr 2017 06:33:09 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l45si17823251qtf.37.2017.04.05.06.33.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 05 Apr 2017 06:33:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvl3c-0002h4-JB for patch@linaro.org; Wed, 05 Apr 2017 09:33:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvkvz-0004hf-8U for qemu-devel@nongnu.org; Wed, 05 Apr 2017 09:25:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvkvy-0000LU-FY for qemu-devel@nongnu.org; Wed, 05 Apr 2017 09:25:15 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:33752) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cvkvy-0000L8-99 for qemu-devel@nongnu.org; Wed, 05 Apr 2017 09:25:14 -0400 Received: by mail-wr0-x232.google.com with SMTP id w43so14050803wrb.0 for ; Wed, 05 Apr 2017 06:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/9qPGLnIfnyBdr0zN+1EuOxX+IvmXq8/A12GO2IcCiI=; b=BfWsbeRhhz0iTfNWvkWd6Ff2qLrZyInlqgdSLHpBJZFuPYLvLfLxyh3ZvSsaDl3wu+ 6MDlrZTcAfJ+f4eqQUrR6EC9Xf5HngK/6Xn5Mc5L21dpzpXVEHL8JjJOYEhbTaLqoXr+ L6l+8lMNyLn9mLaLlPVrd4hjmQ5fJLuxw7Tys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/9qPGLnIfnyBdr0zN+1EuOxX+IvmXq8/A12GO2IcCiI=; b=WCZu1ZDE9yOaVi7n6HEOxR6dXPE28mdTWbBSk8ppqCv8OdqjmYp/MMAOhbu+REmm2A 2aVkYhqIhFbRsTirFyJYdTrTnsSuXBV+IqvNdRrwg4Ck/NC723O4M7A3/55Js2nLhKb/ vTn8pwSunGUu821KKXjHeuF4WZ/hLNg1mJfenYwSxFCsNnmvKETFXkndhnPjoxME8PG/ E0ZsHmzlJZit9tKqxCxDSpjGteCQSlqjahv8456dyrWOPO+0jJCOE6xgzdIOaZAji/cO 0EmyjIDEEeGNQoK+cmBcIiXfDWlK/0WWyhnRwnJ55C0GpTtJSAorP2rMygY2Stz9e7ow nj7w== X-Gm-Message-State: AFeK/H1DmZrza3tku5yfwIW+FGd6neLJXDcqa0G9Dwx4Hn9fqhFtLWZJEVFvJtzR2Gk8xZri X-Received: by 10.223.172.129 with SMTP id o1mr23246209wrc.121.1491398712780; Wed, 05 Apr 2017 06:25:12 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t21sm22350571wmd.19.2017.04.05.06.25.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Apr 2017 06:25:07 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id DF3DC3E1058; Wed, 5 Apr 2017 14:25:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: dovgaluk@ispras.ru, rth@twiddle.net, pbonzini@redhat.com Date: Wed, 5 Apr 2017 14:25:02 +0100 Message-Id: <20170405132503.32125-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170405132503.32125-1-alex.bennee@linaro.org> References: <20170405132503.32125-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::232 Subject: [Qemu-devel] [PATCH v2 11/12] cpus: call cpu_update_icount on read X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mttcg@listserver.greensocs.com, peter.maydell@linaro.org, nikunj@linux.vnet.ibm.com, Peter Crosthwaite , a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, bobby.prani@gmail.com, =?utf-8?q?Alex_Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This ensures each time the vCPU thread reads the icount we update the master timer_state.qemu_icount field. This way as long as updates are in BQL protected sections (which they should be) the main-loop can never come to update the log and find time has gone backwards. Signed-off-by: Alex Bennée --- cpus.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.11.0 diff --git a/cpus.c b/cpus.c index ff75af449a..63de033cc8 100644 --- a/cpus.c +++ b/cpus.c @@ -246,19 +246,17 @@ void cpu_update_icount(CPUState *cpu) int64_t cpu_get_icount_raw(void) { - int64_t icount; CPUState *cpu = current_cpu; - icount = atomic_read(&timers_state.qemu_icount); if (cpu && cpu->running) { if (!cpu->can_do_io) { fprintf(stderr, "Bad icount read\n"); exit(1); } /* Take into account what has run */ - icount += cpu_get_icount_executed(cpu); + cpu_update_icount(cpu); } - return icount; + return atomic_read(&timers_state.qemu_icount); } /* Return the virtual CPU time, based on the instruction counter. */