Received: from eggs.gnu.org ([2001:4830:134:3::10]:41474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWppT-0007HW-67 for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:49:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWppN-0000qM-C9 for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:49:39 -0400 Received: from mail-ee0-x234.google.com ([2a00:1450:4013:c00::234]:42952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWppN-0000qA-4U for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:49:33 -0400 Received: by mail-ee0-f52.google.com with SMTP id c41so1158684eek.25 for ; Thu, 17 Oct 2013 08:49:32 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 17 Oct 2013 17:48:53 +0200 Message-Id: <1382024935-28297-16-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 15/17] icount: document (future) locking rules for icount List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Reviewed-by: Alex Bligh Signed-off-by: Paolo Bonzini --- cpus.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cpus.c b/cpus.c index 34d5e04..6203d98 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 { /* Protected by BQL. */ @@ -235,6 +240,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. */ -- 1.8.3.1