[PATCH] Fix atomic_full_barrier on x86 and x86_64.

Torvald Riegel triegel@redhat.com
Wed Oct 29 18:19:00 GMT 2014


Currently, x86 and x86_64 do not define any of the barriers.  The
generic default for the barriers is that full barriers are just compiler
barriers and read and write barriers default to using the full barrier
definition.  On x86 and x86_64, however, only read/write barriers (ie,
acquire and release fences in how glibc uses them) are just compiler
barriers -- a full barrier needs an mfence instruction.  This patch
defines atomic_full_barrier accordingly without making read/write
barriers stronger than compiler barriers.

The only use of atomic_full_barrier on x86/x86_64 is in
sysdeps/nptl/fork.c, but there, ISTM that this actually only needs an
acquire barrier.  So, this patch doesn't fix existing bugs in *current*
code, and only makes fork a tiny tiny bit slower.

Nonetheless, there are other uses of full barriers in generic code
(e.g., semaphores).  Those don't apply for x86/x86_64 because we
currently have arch-specific code for those, but would if we start using
the generic code on x86 too (and we couldn't do until we fix the x86
full barrier).

        * sysdeps/x86_64/bits/atomic.h: (atomic_full_barrier,
        atomic_read_barrier, atomic_write_barrier): Define.
        * sysdeps/i386/i486/bits/atomic.h (atomic_full_barrier,
        atomic_read_barrier, atomic_write_barrier): Define.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: x86-atomic_full_barrier.patch
Type: text/x-patch
Size: 1523 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20141029/da7b72e6/attachment.bin>


More information about the Libc-alpha mailing list