From owner-freebsd-threads@FreeBSD.ORG  Mon Apr 23 09:40:19 2012
Return-Path: <owner-freebsd-threads@FreeBSD.ORG>
Delivered-To: freebsd-threads@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id B081B1065680
	for <freebsd-threads@freebsd.org>; Mon, 23 Apr 2012 09:40:19 +0000 (UTC)
	(envelope-from slw@zxy.spb.ru)
Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98])
	by mx1.freebsd.org (Postfix) with ESMTP id 642148FC19
	for <freebsd-threads@freebsd.org>; Mon, 23 Apr 2012 09:40:19 +0000 (UTC)
Received: from slw by zxy.spb.ru with local (Exim 4.69 (FreeBSD))
	(envelope-from <slw@zxy.spb.ru>)
	id 1SMFlD-000Eno-CU; Mon, 23 Apr 2012 13:40:43 +0400
Date: Mon, 23 Apr 2012 13:40:43 +0400
From: Slawa Olhovchenkov <slw@zxy.spb.ru>
To: Fengwei yin <yfw.bsd@gmail.com>
Message-ID: <20120423094043.GS32749@zxy.spb.ru>
References: <CAPHpMu=DOGQ=TuFeYH7bH8hVwteT4Q3k67-mvoOFob6P3Y506w@mail.gmail.com>
	<20120423084120.GD76983@zxy.spb.ru>
	<CAPHpMu=kCwhf1RV_sYBDWDPL8368YTMLXge4L_g_F4AkTX1H5g@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <CAPHpMu=kCwhf1RV_sYBDWDPL8368YTMLXge4L_g_F4AkTX1H5g@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-SA-Exim-Connect-IP: <locally generated>
X-SA-Exim-Mail-From: slw@zxy.spb.ru
X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false
Cc: jack.ren@intel.com, freebsd-threads@freebsd.org
Subject: Re: About the memory barrier in BSD libc
X-BeenThere: freebsd-threads@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Threading on FreeBSD <freebsd-threads.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-threads>, 
	<mailto:freebsd-threads-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-threads>
List-Post: <mailto:freebsd-threads@freebsd.org>
List-Help: <mailto:freebsd-threads-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-threads>,
	<mailto:freebsd-threads-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 23 Apr 2012 09:40:19 -0000

On Mon, Apr 23, 2012 at 05:32:24PM +0800, Fengwei yin wrote:

> On Mon, Apr 23, 2012 at 4:41 PM, Slawa Olhovchenkov <slw@zxy.spb.ru> wrote:
> > On Mon, Apr 23, 2012 at 02:56:03PM +0800, Fengwei yin wrote:
> >
> >> Hi list,
> >> If this is not correct question on the list, please let me know and
> >> sorry for noise.
> >>
> >> I have a question regarding the BSD libc for SMP arch. I didn't see
> >> memory barrier used in libc.
> >> How can we make sure it's safe on SMP arch?
> >
> > /usr/include/machine/atomic.h:
> >
> > #define mb() š š__asm __volatile("lock; addl $0,(%%esp)" : : : "memory")
> > #define wmb() š __asm __volatile("lock; addl $0,(%%esp)" : : : "memory")
> > #define rmb() š __asm __volatile("lock; addl $0,(%%esp)" : : : "memory")
> >
> 
> Thanks for the information. But it looks no body use it in libc.

I think no body in libc need memory barrier: libc don't work with
peripheral, for atomic opertions used different macros.