From owner-svn-src-head@FreeBSD.ORG Fri Dec 5 21:17:54 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55C0E106564A; Fri, 5 Dec 2008 21:17:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 451368FC13; Fri, 5 Dec 2008 21:17:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mB5LHsvR073412; Fri, 5 Dec 2008 21:17:54 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mB5LHshQ073411; Fri, 5 Dec 2008 21:17:54 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200812052117.mB5LHshQ073411@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 5 Dec 2008 21:17:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185651 - head/sys/i386/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2008 21:17:54 -0000 Author: kib Date: Fri Dec 5 21:17:54 2008 New Revision: 185651 URL: http://svn.freebsd.org/changeset/base/185651 Log: Unconditionally use locked addition of zero to tip of the stack for memory barriers on i386. It works as a serialization instruction on all IA32 CPUs. Alternative solution of using {s,l,}fence requires run-time checking of the presense of the corresponding SSE or SSE2 extensions, and possible boot-time patching of the kernel text. Suggested by: many Modified: head/sys/i386/include/atomic.h Modified: head/sys/i386/include/atomic.h ============================================================================== --- head/sys/i386/include/atomic.h Fri Dec 5 21:17:19 2008 (r185650) +++ head/sys/i386/include/atomic.h Fri Dec 5 21:17:54 2008 (r185651) @@ -32,20 +32,9 @@ #error this file needs sys/cdefs.h as a prerequisite #endif - -#if defined(I686_CPU) -#define mb() __asm__ __volatile__ ("mfence;": : :"memory") -#define wmb() __asm__ __volatile__ ("sfence;": : :"memory") -#define rmb() __asm__ __volatile__ ("lfence;": : :"memory") -#else -/* - * do we need a serializing instruction? - */ -#define mb() -#define wmb() -#define rmb() -#endif - +#define mb() __asm __volatile("lock;addl $0,(%esp)") +#define wmb() __asm __volatile("lock;addl $0,(%esp)") +#define rmb() __asm __volatile("lock;addl $0,(%esp)") /* * Various simple operations on memory, each of which is atomic in the