Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Oct 2014 14:55:46 +0100
From:      David Chisnall <theraven@FreeBSD.org>
To:        Mateusz Guzik <mjguzik@gmail.com>
Cc:        Hans Petter Selasky <hps@selasky.org>, svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
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...
Message-ID:  <C126C0C6-C688-4F8B-A85D-9B94B45AECFC@FreeBSD.org>
In-Reply-To: <20141016134109.GB10350@dft-labs.eu>
References:  <201410151340.s9FDeUFQ049767@svn.freebsd.org> <20141016123908.GA10350@dft-labs.eu> <543FC86C.2050509@selasky.org> <20141016134109.GB10350@dft-labs.eu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 16 Oct 2014, at 14:41, Mateusz Guzik <mjguzik@gmail.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C126C0C6-C688-4F8B-A85D-9B94B45AECFC>