Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Apr 2012 09:28:13 +0800
From:      Fengwei yin <yfw.bsd@gmail.com>
To:        Ricardo Nabinger Sanchez <rnsanchez@wait4.org>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: About the memory barrier in BSD libc
Message-ID:  <CAPHpMukaTA5nmxFGTNgob_gLQMYZuKo6ErKZqpt3k70C91ayXA@mail.gmail.com>
In-Reply-To: <jn9v4s$hij$1@dough.gmane.org>
References:  <CAPHpMu=DOGQ=TuFeYH7bH8hVwteT4Q3k67-mvoOFob6P3Y506w@mail.gmail.com> <20120423084120.GD76983@zxy.spb.ru> <jn9v4s$hij$1@dough.gmane.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Apr 26, 2012 at 6:51 AM, Ricardo Nabinger Sanchez
<rnsanchez@wait4.org> wrote:
> On Mon, 23 Apr 2012 12:41:20 +0400, Slawa Olhovchenkov wrote:
>
>> /usr/include/machine/atomic.h:
>>
>> #define mb() =A0 =A0__asm __volatile("lock; addl $0,(%%esp)" : : : "memo=
ry")
>> #define wmb() =A0 __asm __volatile("lock; addl $0,(%%esp)" : : : "memory=
")
>> #define rmb() =A0 __asm __volatile("lock; addl $0,(%%esp)" : : : "memory=
")
>
> Somewhat late on this topic, but I'd like to understand why issue a write
> on %esp, which would invalidate (%esp) on other cores --- thus forcing a
> miss on them?

The key here is prefix "lock:" which could be considered as "mfence" on
modern CPU.

>
> Instead, why not issue "mfence" (mb), "sfence" (wmb), and "lfence" (rmb)?
>
Not all x86 family support "fence" instruction. "lock" prefix works for all=
.

> Cheers
>
> --
> Ricardo Nabinger Sanchez =A0 =A0 =A0 =A0 =A0 http://rnsanchez.wait4.org/
> =A0"Left to themselves, things tend to go from bad to worse."
>
> _______________________________________________
> freebsd-threads@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-threads
> To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org=
"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPHpMukaTA5nmxFGTNgob_gLQMYZuKo6ErKZqpt3k70C91ayXA>