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

Matt Sealey matt at genesi-usa.com
Wed Oct 1 02:43:32 UTC 2008


Peter Grehan wrote:
> Hi Matt,
> 
>> Isn't there some kind of semaphore primitive in FreeBSD that can be
>> used?
> 
>  The issue is the OpenSolaris ZFS code that makes liberal use of calls 
> such as atomic_add_64(&ptr_to_uint64).

Indeed I had a look at the ZFS-FUSE project a while back, had a lot of
discussion with the developer, and even got Tom Riddle of Sun involved
in implementing a lot of the 32-bit atomicity code which wasn't present
in Solaris at the time.

> global lock for all 64-bit atomic operations, but it would be better if 
> this could be done without such workarounds on 32-bit ppc.

What makes this any different to the Giant Lock problem?

I don't suppose it needs to be TOO fine grained - after all there are still
big locks in FreeBSD, Linux and pick-another-OS, they are just not so clumsy
as the old FreeBSD Giant or Linux's equivalent.

Stripping it down so that you have many 64-bit atomic access locks first,
would be probably an easier task than attempting to come up with some
clever way of implementing 64-bit atomicity on all 32-bit PPC processors.

Why not simply access protect individual structures? For instance anything
which you have to update some member in an atomic manner, lock the entire
structure. Other atomic accesses can be made to other structures in
parallel (within reason, since PPC can only hold one reservation at a
time, so trying to get two locks in tandem will fail, but in this case,
one will work, the atomic update will happen, and the other lock attempt
will spin until it succeeds.. and then that atomic update will happen)

-- 
Matt Sealey <matt at genesi-usa.com>
Genesi, Manager, Developer Relations



More information about the freebsd-ppc mailing list