From owner-svn-src-projects@FreeBSD.ORG Tue Sep 18 10:16:00 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52B50106566C; Tue, 18 Sep 2012 10:16:00 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id 057FC8FC12; Tue, 18 Sep 2012 10:16:00 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:ecff:a137:3a22:244] (unknown [IPv6:2001:7b8:3a7:0:ecff:a137:3a22:244]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 25CD75C59; Tue, 18 Sep 2012 12:15:58 +0200 (CEST) Message-ID: <505849DB.3090704@FreeBSD.org> Date: Tue, 18 Sep 2012 12:15:55 +0200 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20120905 Thunderbird/16.0 MIME-Version: 1.0 To: attilio@FreeBSD.org References: <201207301350.q6UDobCI099069@svn.freebsd.org> <201207301732.33474.jhb@freebsd.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Davide Italiano , src-committers@freebsd.org, John Baldwin , Jeff Roberson , svn-src-projects@freebsd.org, Konstantin Belousov Subject: Re: svn commit: r238907 - projects/calloutng/sys/kern X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Sep 2012 10:16:00 -0000 On 2012-09-18 02:13, Attilio Rao wrote: > On Thu, Aug 2, 2012 at 9:56 PM, Attilio Rao wrote: >> On 7/30/12, John Baldwin 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(). -Dimitry [1]: