Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Sep 2008 20:20:05 +0200
From:      Rafal Jaworowski <raj@semihalf.com>
To:        Marcel Moolenaar <xcllnt@mac.com>
Cc:        freebsd-ppc@freebsd.org
Subject:   64-bit atomic ops on 32-bit CPU -- was: ZFS .. on PowerPC ?
Message-ID:  <48DA84D5.4010109@semihalf.com>
In-Reply-To: <60ACBA3B-927C-4F2C-8680-A6B40B81E06C@mac.com>
References:  <B4645B39-9D9D-49C5-8F69-55704CD2F6AA@delfi-konsult.com> <60ACBA3B-927C-4F2C-8680-A6B40B81E06C@mac.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Marcel Moolenaar wrote:
> ZFS requires 64-bit atomic operations, which
> PowerPC doesn't have. So, we can't build the

Hi Marcel,
These are my [long overdue, sorry :-)] notes regarding 64-bit ops on the
32-bit machine.

My concept is based on the fact that the reservation granule is cache-line
size e.g. on Book-E CPU this is 32 bytes (8 words). With this assumption you
can have a 64-bit atomic operation like the following:

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

b.) assume our 64-bit object uses word (W1) and word 2 (W2) within the given
granule

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 have implementated the above scheme for e500 SMP purposes (atomic access to
3- or more word objects) and it's working fine in my environment where the
atomic objects are allocated and managed "manually".

The problem with this, however, is general-purpose applications like in ZFS,
when there's no direct control over the atomic objects. I don't know how to
ensure (in a transparent way) that ZFS (or whatever consumer of
atomic_cmpset_64() and friends) put all words of the compound atomic object
within one granule, which is a requirement here...

Comments?

Rafal



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48DA84D5.4010109>