From owner-svn-src-all@FreeBSD.ORG Sat Jun 15 12:56:59 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6E29B85D; Sat, 15 Jun 2013 12:56:59 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 086111725; Sat, 15 Jun 2013 12:56:58 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.6/8.14.6/ALCHEMY.FRANKEN.DE) with ESMTP id r5FCupKB022489; Sat, 15 Jun 2013 14:56:51 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.6/8.14.6/Submit) id r5FCupNP022488; Sat, 15 Jun 2013 14:56:51 +0200 (CEST) (envelope-from marius) Date: Sat, 15 Jun 2013 14:56:51 +0200 From: Marius Strobl To: Ed Schouten Subject: Re: svn commit: r251782 - head/sys/sparc64/sparc64 Message-ID: <20130615125651.GH91573@alchemy.franken.de> References: <201306150821.r5F8Lst5089231@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201306150821.r5F8Lst5089231@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jun 2013 12:56:59 -0000 On Sat, Jun 15, 2013 at 08:21:54AM +0000, Ed Schouten wrote: > Author: ed > Date: Sat Jun 15 08:21:54 2013 > New Revision: 251782 > URL: http://svnweb.freebsd.org/changeset/base/251782 > > Log: > Stick to using the documented atomic(9) API. > > The atomic_store_ptr() function is not part of the atomic(9) API. We > only provide a version with a release barrier. > > Modified: > head/sys/sparc64/sparc64/pmap.c > > Modified: head/sys/sparc64/sparc64/pmap.c > ============================================================================== > --- head/sys/sparc64/sparc64/pmap.c Sat Jun 15 08:15:22 2013 (r251781) > +++ head/sys/sparc64/sparc64/pmap.c Sat Jun 15 08:21:54 2013 (r251782) > @@ -2246,7 +2246,7 @@ pmap_activate(struct thread *td) > pm->pm_context[curcpu] = context; > #ifdef SMP > CPU_SET_ATOMIC(PCPU_GET(cpuid), &pm->pm_active); > - atomic_store_ptr((uintptr_t *)PCPU_PTR(pmap), (uintptr_t)pm); > + atomic_store_rel_ptr((uintptr_t *)PCPU_PTR(pmap), (uintptr_t)pm); > #else > CPU_SET(PCPU_GET(cpuid), &pm->pm_active); > PCPU_SET(pmap, pm); Semantically, this change is wrong; what we really need here is an acquire variant. Using the release variant instead happens to also work - albeit additionally wastes CPU cycles for the write memory barrier - because in total store order, atomic operations implicitly include the read memory barrier necessary for acquire semantics. In other words, atomic(9) is in dare need of atomic_store_acq_(). Marius