From owner-svn-src-head@FreeBSD.ORG Thu Oct 16 13:55:51 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A10D4F0A; Thu, 16 Oct 2014 13:55:51 +0000 (UTC) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cloud.theravensnest.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 6F481950; Thu, 16 Oct 2014 13:55:50 +0000 (UTC) Received: from c116.sec.cl.cam.ac.uk (c116.sec.cl.cam.ac.uk [128.232.18.116]) (authenticated bits=0) by theravensnest.org (8.14.9/8.14.9) with ESMTP id s9GDtke8041576 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Thu, 16 Oct 2014 13:55:48 GMT (envelope-from theraven@FreeBSD.org) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: svn commit: r273135 - in head/sys: contrib/rdma/krping dev/cxgbe/iw_cxgbe ofed/drivers/infiniband/core ofed/drivers/infiniband/hw/mlx4 ofed/drivers/infiniband/hw/mthca ofed/drivers/infiniband/ulp/i... From: David Chisnall In-Reply-To: <20141016134109.GB10350@dft-labs.eu> Date: Thu, 16 Oct 2014 14:55:46 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201410151340.s9FDeUFQ049767@svn.freebsd.org> <20141016123908.GA10350@dft-labs.eu> <543FC86C.2050509@selasky.org> <20141016134109.GB10350@dft-labs.eu> To: Mateusz Guzik X-Mailer: Apple Mail (2.1878.6) Cc: Hans Petter Selasky , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Oct 2014 13:55:51 -0000 On 16 Oct 2014, at 14:41, Mateusz Guzik wrote: > Well, atomic_set can be as simple as v->counter =3D i; (which btw will > make it look identical to linux version). This should not give any > measureable effect unless atomic_set on given var is abused quite a = lot. v->counter =3D i does not establish a happens-before relationship and so = there is no guarantee that the write will be visible to other threads = until something else does establish such a relationship. The compiler = and CPU are both free to reorder the store at will, and to elide it. There is a reason that C11 provides atomic_store and atomic_load = operations. It sounds like Linux wants the relaxed consistency model = here, which *is* equivalent to v->counter =3D i on x86, but *will not be = the same* on any weakly-ordered architecture (e.g. ARM). Given that we have a stdatomic.h in the base system, which works with = all of our supported compilers, please consider using the functionality = provided by the C standard to solve your exact problem. David