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...

David Chisnall theraven at FreeBSD.org
Thu Oct 16 13:55:51 UTC 2014


On 16 Oct 2014, at 14:41, Mateusz Guzik <mjguzik at gmail.com> wrote:

> Well, atomic_set can be as simple as v->counter = 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 = 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 = 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



More information about the svn-src-head mailing list