atomic ops
Mateusz Guzik
mjguzik at gmail.com
Thu Apr 9 06:14:54 UTC 2015
On Tue, Oct 28, 2014 at 03:52:22AM +0100, Mateusz Guzik wrote:
[scratching old content so that I hopefully re-state it nicer]
I would like to reviwe the discussion about memory barriers provided in
the kernel.
The kernel (at least on amd64) lacks lightweight barriers providing only
following guarantees:
- all writes are completed prior to given point
- all reads are completed prior to given point
On amd64 such barriers require only compiler barrier, and as such
obviously beat currently used operations like load_acq (which uses
cmpxchg).
Example consumer which would benefit greatly from such barriers is
seq.h:
https://svnweb.freebsd.org/base/head/sys/sys/seq.h?view=markup
_load_acq on amd64 provides full barrier and it was noted we should not
change that in order to not break possible 3rd party consumers.
Also I don't see any alternative naming convention trying to stick to
this scheme that we could use.
As such I propose stealing naming from Linux and introduction of smp_wmb
and smp_rmb macros providing aforementioned funcionality.
So for amd64 this would be:
#define smp_wmb() __compiler_membar()
#define smp_rmb() __compiler_membar()
Any objections?
I'm happy to talk to arch maintainers in order to get relevant
implementations for all architectures.
--
Mateusz Guzik <mjguzik gmail.com>
More information about the freebsd-arch
mailing list