From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anNdA-0003g7-3J for qemu-devel@nongnu.org; Tue, 05 Apr 2016 05:50:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anNd8-0001Dg-R2 for qemu-devel@nongnu.org; Tue, 05 Apr 2016 05:50:40 -0400 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:37087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anNd8-0001DZ-Jl for qemu-devel@nongnu.org; Tue, 05 Apr 2016 05:50:38 -0400 Received: by mail-wm0-x232.google.com with SMTP id n3so14000083wmn.0 for ; Tue, 05 Apr 2016 02:50:38 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 5 Apr 2016 11:50:15 +0200 Message-Id: <1459849818-26649-13-git-send-email-pbonzini@redhat.com> In-Reply-To: <1459849818-26649-1-git-send-email-pbonzini@redhat.com> References: <1459849818-26649-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL 12/15] cpus: don't use atomic_read for vm_clock_warp_start List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= From: Alex Bennée As vm_clock_warp_start is a 64 bit value this causes problems for the compiler trying to come up with a suitable atomic operation on 32 bit hosts. Because the variable is protected by vm_clock_seqlock, we check its value inside a seqlock critical section. Signed-off-by: Alex Bennée Message-Id: <1459780549-12942-2-git-send-email-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- cpus.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 8ae4777..cbeb1f6 100644 --- a/cpus.c +++ b/cpus.c @@ -338,10 +338,18 @@ static int64_t qemu_icount_round(int64_t count) static void icount_warp_rt(void) { + unsigned seq; + int64_t warp_start; + /* The icount_warp_timer is rescheduled soon after vm_clock_warp_start * changes from -1 to another value, so the race here is okay. */ - if (atomic_read(&vm_clock_warp_start) == -1) { + do { + seq = seqlock_read_begin(&timers_state.vm_clock_seqlock); + warp_start = vm_clock_warp_start; + } while (seqlock_read_retry(&timers_state.vm_clock_seqlock, seq)); + + if (warp_start == -1) { return; } -- 2.5.5