From owner-freebsd-threads@FreeBSD.ORG Mon Apr 23 11:38:15 2012 Return-Path: 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 1D6881065675 for ; Mon, 23 Apr 2012 11:38:15 +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 BD8F88FC0A for ; Mon, 23 Apr 2012 11:38:14 +0000 (UTC) Received: from slw by zxy.spb.ru with local (Exim 4.69 (FreeBSD)) (envelope-from ) id 1SMHbK-000Hxx-A9; Mon, 23 Apr 2012 15:38:38 +0400 Date: Mon, 23 Apr 2012 15:38:38 +0400 From: Slawa Olhovchenkov To: Fengwei yin Message-ID: <20120423113838.GT32749@zxy.spb.ru> References: <20120423084120.GD76983@zxy.spb.ru> <20120423094043.GS32749@zxy.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2012 11:38:15 -0000 On Mon, Apr 23, 2012 at 07:26:54PM +0800, Fengwei yin wrote: > On Mon, Apr 23, 2012 at 5:40 PM, Slawa Olhovchenkov wrote: > > On Mon, Apr 23, 2012 at 05:32:24PM +0800, Fengwei yin wrote: > > > >> On Mon, Apr 23, 2012 at 4:41 PM, Slawa Olhovchenkov 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. > > If we check the usage of __sinit(), it is a typical singleton pattern which > needs memory barrier to make sure no potential SMP issue. > > Or did I miss something here? What architecture with cache incoherency and FreeBSD support?