From owner-freebsd-threads@FreeBSD.ORG Wed Apr 25 22:55:18 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 71B951065676 for ; Wed, 25 Apr 2012 22:55:18 +0000 (UTC) (envelope-from gofdt-freebsd-threads@m.gmane.org) Received: from plane.gmane.org (plane.gmane.org [80.91.229.3]) by mx1.freebsd.org (Postfix) with ESMTP id D95288FC0A for ; Wed, 25 Apr 2012 22:55:14 +0000 (UTC) Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SNB71-0007PK-Vz for freebsd-threads@freebsd.org; Thu, 26 Apr 2012 00:55:03 +0200 Received: from 189.32.123.86 ([189.32.123.86]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 26 Apr 2012 00:55:03 +0200 Received: from rnsanchez by 189.32.123.86 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 26 Apr 2012 00:55:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-threads@freebsd.org From: Ricardo Nabinger Sanchez Date: Wed, 25 Apr 2012 22:51:08 +0000 (UTC) Lines: 19 Message-ID: References: <20120423084120.GD76983@zxy.spb.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 189.32.123.86 User-Agent: Pan/0.134 (Wait for Me; GIT cb32159 master) 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: Wed, 25 Apr 2012 22:55:18 -0000 On Mon, 23 Apr 2012 12:41:20 +0400, Slawa Olhovchenkov wrote: > /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") 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? Instead, why not issue "mfence" (mb), "sfence" (wmb), and "lfence" (rmb)? Cheers -- Ricardo Nabinger Sanchez http://rnsanchez.wait4.org/ "Left to themselves, things tend to go from bad to worse."