From patchwork Tue Apr 5 09:50:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 65062 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp361887lbc; Tue, 5 Apr 2016 02:55:43 -0700 (PDT) X-Received: by 10.140.136.70 with SMTP id 67mr19159509qhi.46.1459850143101; Tue, 05 Apr 2016 02:55:43 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z2si25580176qkg.60.2016.04.05.02.55.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Apr 2016 02:55:43 -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=@gmail.com; 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 Received: from localhost ([::1]:35684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anNi2-0004Cx-MQ for patch@linaro.org; Tue, 05 Apr 2016 05:55:42 -0400 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) 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 :mime-version:content-transfer-encoding; bh=Gg81//AFZ45bWAKIe2acVZ9D5UxFwdO0r3MrCB6oGdM=; b=gEZVLZrcITyaBGi5tFgWfUOTXDlDF1u+Gwq+Zz15vDlk4apL9wlg4l8sPkkai3LW87 CD8dG+U+s3SimvjP2w2cIwXX5C8t8SPEBOGYwe+B2QsJ/5OjjVDACMpl59cgggQNDe3F nQpxXWF3EWE73tIt9Wv/IvmNLgLJaJC3he/5z0AanbQewE8D+a/L5cshFsfE9HyZtrva SAY3oxbDiGqCvRUdJ8OZJWeCILjjRS4yU4ApKhzjcRsfGFvDOHOAjubKob6Az/6f1AYg bHfQoxToEQRcEv2JbRDNpxcnZtHUFBul/i+CY/pYRJqIjyWCkzhlwAvFiJLqNCG105lf 5Vuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Gg81//AFZ45bWAKIe2acVZ9D5UxFwdO0r3MrCB6oGdM=; b=Duzo+zuTqGxMjbupiOMv1ST+l0sKGPchSTaJWlWLnxO0PEoOlQfXKKk4IK9zrDZPHD et6mxeq8F/hYVwKdU1cEU7aQR/cX+AqJuyeLGokG1TG7rVSkzukrzZ9Z+O5Hu426skfL 8/333xSAeu0zsy9JX34UiUCDeZl+vuKOQd2eDVqXViPn2U+hubu46OoKWivzi1soxF34 eff+datKVeaCNRjovVbFbswbuAvAyrb50veh/BYmkXDPtsRoJOD3XgeFzaUXwbRAC6LB y1ZSIDHxVwGpJqqoSkCWI2DbBkRBVfzyv4lqglr0FYbUeqQ7hnr4p7qIpIp7Uu071t8f GC6Q== X-Gm-Message-State: AD7BkJK2xnhBCtqZdKCAHusPz0Mh+p7JmR8Cth1nI/WudmpmR8Lp1EzS6MLEecdezCYNsg== X-Received: by 10.28.45.212 with SMTP id t203mr16784406wmt.71.1459849837925; Tue, 05 Apr 2016 02:50:37 -0700 (PDT) Received: from donizetti.lan (94-39-141-76.adsl-ull.clienti.tiscali.it. [94.39.141.76]) by smtp.gmail.com with ESMTPSA id ka4sm33721377wjc.47.2016.04.05.02.50.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Apr 2016 02:50:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 5 Apr 2016 11:50:15 +0200 Message-Id: <1459849818-26649-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.5.5 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 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: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [Qemu-devel] [PULL 12/15] 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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(-) -- 2.5.5 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; }