From owner-freebsd-ppc@FreeBSD.ORG Wed Sep 24 22:11:10 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 293711065687 for ; Wed, 24 Sep 2008 22:11:10 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout017.mac.com (asmtpout017.mac.com [17.148.16.92]) by mx1.freebsd.org (Postfix) with ESMTP id 0C4208FC19 for ; Wed, 24 Sep 2008 22:11:10 +0000 (UTC) (envelope-from xcllnt@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed Received: from [192.168.1.95] (209-128-86-226.bayarea.net [209.128.86.226]) by asmtp017.mac.com (Sun Java(tm) System Messaging Server 6.3-7.03 (built Aug 7 2008; 32bit)) with ESMTPSA id <0K7Q00AMG0AKE410@asmtp017.mac.com> for freebsd-ppc@freebsd.org; Wed, 24 Sep 2008 15:11:09 -0700 (PDT) Message-id: <2AD479FA-794C-421A-AF53-C10BBF0826DC@mac.com> From: Marcel Moolenaar To: Rafal Jaworowski In-reply-to: <111399E3-2BC7-4724-8AFB-A40F2A47E66D@mac.com> Date: Wed, 24 Sep 2008 15:11:08 -0700 References: <60ACBA3B-927C-4F2C-8680-A6B40B81E06C@mac.com> <48DA84D5.4010109@semihalf.com> <48DA99F8.7070904@semihalf.com> <111399E3-2BC7-4724-8AFB-A40F2A47E66D@mac.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 22:11:10 -0000 On Sep 24, 2008, at 2:07 PM, Marcel Moolenaar wrote: > Ok. Let's assume we lose the reservation and we're > forced to loop and try again. Step 2 then reads W2, > which on a retry is the word written in step 4. As > such, if we have to loop and retry X times, then > the atomic increment would increment by X and not > 1. > > I don't think an unconditional write to W2 will > work if we don't preserve the origional value of > W2. What about the following algorithm: /* Atomically read 64-bit entity. */ 1: lwarx P[0] ldw P[1] stwcx P[0] b.fail 1 /* Perform operation on 64-bit entity. */ {Q[0],Q[1]} = operation({P[0],P[1]}) /* * Pseudo-atomically write 64-bit value. * The 64-bit entity may have been clobbered * by this time. */ lwarx t[0] ldw t[1] cmp t[0],P[0] b.ne 1 cmp t[1],P[1] b.ne 1 stw Q[1] stwcx Q[0] b.ok 2 stw P[1] b 1 2: sync ret Interrupts should be disabled to minimize the time the 64-bit entity is inconsistent WRT non-atomic reads. Thoughts? -- Marcel Moolenaar xcllnt@mac.com