svn commit: r238907 - projects/calloutng/sys/kern

Konstantin Belousov kostikbel at gmail.com
Tue Sep 18 10:22:48 UTC 2012


On Tue, Sep 18, 2012 at 12:15:55PM +0200, Dimitry Andric wrote:
> On 2012-09-18 02:13, Attilio Rao wrote:
> > On Thu, Aug 2, 2012 at 9:56 PM, Attilio Rao <attilio at freebsd.org> wrote:
> >> On 7/30/12, John Baldwin <jhb at freebsd.org> wrote:
> ...
> >> While here, did you consider also:
> >> - Abstracting compiler_memory_barrier() into a MI, compiler dependent function?
> >
> > So what do you think about this patch? (Please double-check the GIT log).
> ...
> 
> > diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
> > index 8224672..fc6a75f 100644
> > --- a/sys/sys/cdefs.h
> > +++ b/sys/sys/cdefs.h
> > @@ -114,6 +114,13 @@
> >   #endif
> >
> >   /*
> > + * Compiler memory barriers, specific to gcc and clang.
> > + */
> > +#if defined(__GNUC__)
> > +#define        __compiler_membar()     __asm __volatile(" " : : : "memory")
> > +#endif
> > +
> > +/*
> >    * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
> >    * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
> >    * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
> 
> Please use gcc's __sync_synchronize() builtin[1] instead, which is
> specifically for this purpose.  Clang also supports it.
> 
> The builtin will emit actual memory barrier instructions, if the target
> architecture supports it, otherwise it will emit the same asm statement
> you show above.  See contrib/gcc/builtins.c, around line 5584, function
> expand_builtin_synchronize().

We do not need CPU barriers there, which are already handled by the atomic
asms. It is only to prevent compiler from exploiting the reorder.
> 
> -Dimitry
> 
> [1]: <http://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html#index-g_t_005f_005fsync_005fsynchronize-2843>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-projects/attachments/20120918/cbe55e60/attachment.pgp


More information about the svn-src-projects mailing list