From patchwork Mon Mar 21 16:23:05 2016 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: 600182 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qTLjv0Zrdz9s2Q for ; Tue, 22 Mar 2016 03:23:47 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=fosWZQfT; dkim-atps=neutral Received: from localhost ([::1]:58846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai2cL-0004fi-6m for incoming@patchwork.ozlabs.org; Mon, 21 Mar 2016 12:23:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai2bt-0003rl-8a for qemu-devel@nongnu.org; Mon, 21 Mar 2016 12:23:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai2bp-0008OT-B8 for qemu-devel@nongnu.org; Mon, 21 Mar 2016 12:23:17 -0400 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:32779) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai2bp-0008OI-4l for qemu-devel@nongnu.org; Mon, 21 Mar 2016 12:23:13 -0400 Received: by mail-wm0-x232.google.com with SMTP id l68so158329122wml.0 for ; Mon, 21 Mar 2016 09:23:13 -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=RLQfIGOi+VYwMFTe2LZ5GpDExhWPArE6V5AODiUc4NE=; b=fosWZQfT4jiHx18xn0xxpGzi9hJuL6bf/uLeRyO/jx/FhEL2IoCQrn0kNGsmsbxE9O bFgnKNCr6HGnuXsHoXd68ndZt0LfZOx4quegDvqjYrzDktelCoVhvQ18/nxBQopLRqn7 8p4LyfT+8JyYMcEwy2VUBFNHr28o4u+ie6kek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RLQfIGOi+VYwMFTe2LZ5GpDExhWPArE6V5AODiUc4NE=; b=UCAAT7OA2b45uL/Y/67XFt9Uv5wNqlPalsrdpJ6peYCsuESlCyTX2KkO1hlBd4wcnd mL8zFm48miZjfawJdEhbl/bu5/00+ScrzW5rgigodiiXa7gp5am3yIfKhfM2OgkYV6tf 9U3qQugdACGRfZB8JgqqZGfXRc/ZAPUGQuK3s5JMEXQCK3gq94R1Fu7qRvy9Ccm3psXg s7BuqYOAzUFE3c1yaniZXCdb6+eDANuyvjluxLMDyPmjY2C0n7HeKE454i6/paIJC7DC 4GdJJagWkgY22kBZGRdHihJu7a56MGn5tgtEeZ1uyYn0c7EP3MyxVW63nU2e22+j2KTZ EHAA== X-Gm-Message-State: AD7BkJJqZA53OHoC0z8HqmR1cAK7E8zd9uB96k4AAUqAvHsVxn9rZZ02tgkG/FMTUZ+qIV0A X-Received: by 10.194.5.36 with SMTP id p4mr31718369wjp.167.1458577392578; Mon, 21 Mar 2016 09:23:12 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id et11sm26156122wjc.30.2016.03.21.09.23.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Mar 2016 09:23:08 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 03FE83E02E9; Mon, 21 Mar 2016 16:23:08 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Mon, 21 Mar 2016 16:23:05 +0000 Message-Id: <1458577386-9984-2-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458577386-9984-1-git-send-email-alex.bennee@linaro.org> References: <1458577386-9984-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::232 Cc: peter.maydell@linaro.org, Peter Crosthwaite , sbruno@freebsd.org, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Subject: [Qemu-devel] [PATCH v1 1/2] cpus: don't use atomic_read for vm_clock_warp_start 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 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. The variable documentation says this is meant to be protected by vm_clock_seqlock so lets just move the code into that section. All other references to vm_clock_warp_start are already protected by the seqlock. Signed-off-by: Alex Bennée --- cpus.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cpus.c b/cpus.c index 23cf7aa..2fd5381 100644 --- a/cpus.c +++ b/cpus.c @@ -338,15 +338,10 @@ static int64_t qemu_icount_round(int64_t count) static void icount_warp_rt(void) { - /* 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) { - return; - } + bool check_clock = false; seqlock_write_lock(&timers_state.vm_clock_seqlock); - if (runstate_is_running()) { + if (vm_clock_warp_start != -1 && runstate_is_running()) { int64_t clock = REPLAY_CLOCK(REPLAY_CLOCK_VIRTUAL_RT, cpu_get_clock_locked()); int64_t warp_delta; @@ -362,11 +357,12 @@ static void icount_warp_rt(void) warp_delta = MIN(warp_delta, delta); } timers_state.qemu_icount_bias += warp_delta; + check_clock = true; } vm_clock_warp_start = -1; seqlock_write_unlock(&timers_state.vm_clock_seqlock); - if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) { + if (check_clock && qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) { qemu_clock_notify(QEMU_CLOCK_VIRTUAL); } }