From owner-freebsd-ppc@FreeBSD.ORG Wed Sep 24 19:30:29 2008 Return-Path: Delivered-To: freebsd-ppc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C8BA1065676 for ; Wed, 24 Sep 2008 19:30:29 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout013.mac.com (asmtpout013.mac.com [17.148.16.88]) by mx1.freebsd.org (Postfix) with ESMTP id 456558FC19 for ; Wed, 24 Sep 2008 19:30:29 +0000 (UTC) (envelope-from xcllnt@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Received: from krussell-lt1.jnpr.net (natint3.juniper.net [66.129.224.36]) by asmtp013.mac.com (Sun Java(tm) System Messaging Server 6.3-7.03 (built Aug 7 2008; 32bit)) with ESMTPSA id <0K7P00BYISUQ0270@asmtp013.mac.com> for freebsd-ppc@freebsd.org; Wed, 24 Sep 2008 12:30:27 -0700 (PDT) Message-id: From: Marcel Moolenaar To: Rafal Jaworowski In-reply-to: <48DA84D5.4010109@semihalf.com> Date: Wed, 24 Sep 2008 12:30:25 -0700 References: <60ACBA3B-927C-4F2C-8680-A6B40B81E06C@mac.com> <48DA84D5.4010109@semihalf.com> X-Mailer: Apple Mail (2.929.2) Cc: freebsd-ppc@freebsd.org Subject: Re: 64-bit atomic ops on 32-bit CPU -- was: ZFS .. on PowerPC ? X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Sep 2008 19:30:29 -0000 On Sep 24, 2008, at 11:20 AM, Rafal Jaworowski wrote: > a.) make sure the whole granule is dedicated for a single object we > want > atomic access to, i.e. in case of a 64-bit object we would use only > 2 words > out of 8 in the given granule and the remaining 6 would be wasted Is this required for correctness? I can see that it is desirable for performance, but I don't think it's needed for correctness. Can you elaborate? > b.) assume our 64-bit object uses word (W1) and word 2 (W2) within > the given > granule Right. This means that 64-bit integrals (i.e. [u]int64_t) should at least be 64-bit aligned. Otherwise you can cross the granule boundary. > Atomic store skeleton (pseudo asm, but you'll get the idea): > > 1. lwarx W1 > > 2. stw W2 > This regular (non-stwcx) store issued from local CPU will not clear > our > reservation on this granule (only external CPUs or other entities' > stores > within this granule can clear it) > > 3. stwcx W1, goto p.1 if not succeeded I don't see a read of W2. In particular, we clobber W2 unconditionally, so we must guarantee that we always read the correct value of W2. Can you elaborate on how an increment would be made atomic? -- Marcel Moolenaar xcllnt@mac.com