64-bit atomic ops on 32-bit CPU -- was: ZFS .. on PowerPC ?

Rafal Jaworowski raj at semihalf.com
Wed Sep 24 18:20:20 UTC 2008


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


More information about the freebsd-ppc mailing list