From patchwork Tue Oct 8 08:47:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 281368 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 A61752C0098 for ; Tue, 8 Oct 2013 19:52:10 +1100 (EST) Received: from localhost ([::1]:35327 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTT1U-0002dJ-Kv for incoming@patchwork.ozlabs.org; Tue, 08 Oct 2013 04:52:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTSxt-000506-4i for qemu-devel@nongnu.org; Tue, 08 Oct 2013 04:48:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTSxk-0003eF-NG for qemu-devel@nongnu.org; Tue, 08 Oct 2013 04:48:25 -0400 Received: from mail-ea0-x231.google.com ([2a00:1450:4013:c01::231]:43014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTSxk-0003dG-GC for qemu-devel@nongnu.org; Tue, 08 Oct 2013 04:48:16 -0400 Received: by mail-ea0-f177.google.com with SMTP id f15so3808769eak.36 for ; Tue, 08 Oct 2013 01:48:15 -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=3ouGDYUXeSyKigypclJHIakNXxfgsDdu27yFLcPMvig=; b=ciMwINk+oScCu5Lk/AiEuI7eXhlusUZH2R9G1S+nZV87INVfEXyOzWq6kECHeYGMRT t+o5TWicTQDPvW6dvf+3F1kx7FQwP7C4M+UsCBUBZt43Xs6t8bvJ2zBA1PHd78g4eol/ MGQggSgBTLXbyIB6sP1LcxHMhLb5hOPOahF7hVo5bbq5hCJLuPCUPP0b+p3OO0E5Rwvq mlwiS4GNdPIQexGFzSZVnnGakvFTMbgaSGnTlBAHtdxaSdkxtnQoKIWHi1rH7G6f3pOr m5fTp8B1HkNEmmKSExnaVBaw/xMZs7QnNdC4VI5jds2j7vy5tHYnWjkQBSODSiLD4K7X zEgQ== X-Received: by 10.14.5.3 with SMTP id 3mr618787eek.49.1381222095504; Tue, 08 Oct 2013 01:48:15 -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:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 8 Oct 2013 10:47:37 +0200 Message-Id: <1381222058-16701-8-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::231 Cc: alex@alex.org.uk Subject: [Qemu-devel] [PATCH 7/8] timers: document (future) locking rules for icount 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 Signed-off-by: Paolo Bonzini Reviewed-by: Alex Bligh --- cpus.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cpus.c b/cpus.c index 01acce2..bc675a4 100644 --- a/cpus.c +++ b/cpus.c @@ -98,17 +98,22 @@ static bool all_cpu_threads_idle(void) /***********************************************************/ /* guest cycle counter */ +/* Protected by TimersState seqlock */ + +/* Compensate for varying guest execution speed. */ +static int64_t qemu_icount_bias; +static int64_t vm_clock_warp_start; /* Conversion factor from emulated instructions to virtual clock ticks. */ static int icount_time_shift; /* Arbitrarily pick 1MIPS as the minimum allowable speed. */ #define MAX_ICOUNT_SHIFT 10 -/* Compensate for varying guest execution speed. */ -static int64_t qemu_icount_bias; + +/* Only written by TCG thread */ +static int64_t qemu_icount; + static QEMUTimer *icount_rt_timer; static QEMUTimer *icount_vm_timer; static QEMUTimer *icount_warp_timer; -static int64_t vm_clock_warp_start; -static int64_t qemu_icount; typedef struct TimersState { int64_t cpu_ticks_prev; @@ -232,6 +237,8 @@ static void icount_adjust(void) int64_t cur_time; int64_t cur_icount; int64_t delta; + + /* Protected by TimersState mutex. */ static int64_t last_delta; /* If the VM is not running, then do nothing. */