Subject: Re: Atomic ops API
To: Johnny Billquist <bqt@softjar.se>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 03/16/2007 08:50:35
On Mar 16, 2007, at 2:25 AM, Johnny Billquist wrote:

> I was just wondering, is the returned value even meaningful?

Apparently, it is used by some code in Solaris (in ZFS) for other than  
just "the swap took place".  I guess they're probably trying to avoid  
having to do an extra read memory barrier in the loop.

> However, for code already using a cas then, I would guess that they  
> check for a return value of ==cmp or !=cmp. So why not have your cas  
> function return that, Jason? That should then not break anything,  
> and that can be implemented internally as a compare_and_store with a  
> simple wrapper to return cmp or ~cmp.

The reason I'd like to return true (store occurred) or false (store  
did not occur) is because it is much more convenient on some of the  
architectures we support to implement it that way.

> Or is some code actually using the return value in some more clever  
> way in case it's not ==cmp.

Someone quoted some code in ZFS that uses it in other ways, yes.

-- thorpej