From patchwork Fri Oct 7 16:57:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 77347 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp363143qge; Fri, 7 Oct 2016 10:18:15 -0700 (PDT) X-Received: by 10.55.134.199 with SMTP id i190mr20345172qkd.195.1475860695707; Fri, 07 Oct 2016 10:18:15 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r84si10551530qkr.160.2016.10.07.10.18.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 07 Oct 2016 10:18:15 -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; 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]:37431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsYml-00032V-66 for patch@linaro.org; Fri, 07 Oct 2016 13:18:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsYTb-0003zO-Go for qemu-devel@nongnu.org; Fri, 07 Oct 2016 12:58:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsYTZ-00082f-NM for qemu-devel@nongnu.org; Fri, 07 Oct 2016 12:58:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsYTZ-000826-GI for qemu-devel@nongnu.org; Fri, 07 Oct 2016 12:58:25 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7A8B2B51DE; Fri, 7 Oct 2016 16:58:24 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-69.ams2.redhat.com [10.36.112.69]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u97Gw4td022714; Fri, 7 Oct 2016 12:58:23 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 7 Oct 2016 18:57:35 +0200 Message-Id: <1475859483-32234-12-git-send-email-pbonzini@redhat.com> In-Reply-To: <1475859483-32234-1-git-send-email-pbonzini@redhat.com> References: <1475859483-32234-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 07 Oct 2016 16:58:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/39] atomic.h: comment on use of atomic_read/set X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée Add some notes on the use of the relaxed atomic access helpers and their importance for defined behaviour in C11's multi-threaded memory model. Signed-off-by: Alex Bennée Message-Id: <20160930213106.20186-3-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- include/qemu/atomic.h | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.7.4 diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index c493f89..c4f6950 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -92,6 +92,12 @@ /* Weak atomic operations prevent the compiler moving other * loads/stores past the atomic operation load/store. However there is * no explicit memory barrier for the processor. + * + * The C11 memory model says that variables that are accessed from + * different threads should at least be done with __ATOMIC_RELAXED + * primitives or the result is undefined. Generally this has little to + * no effect on the generated code but not using the atomic primitives + * will get flagged by sanitizers as a violation. */ #define atomic_read(ptr) \ ({ \