Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation

Nick Piggin
2005-12-16T23:41:52Z

David Howells wrote:

>>It is not even clear that any ll/sc based architectures would need to override
>>an atomic_cmpxchg variant at all because you can assume an unlocked fastpath
>
>
> That's irrelevant. Any arch that has LL/SC almost certainly emulates CMPXCHG
> with LL/SC.
>

It is not irrelevant because many architectures that would care are ll/sc
based and many others have a native cmpxchg ie. cmpxchg wouldn't be a bad
choice for default.

>
>>and not do the additional initial load to prime the cmpxchg.
>
>
> Two points:
>
> (1) LL/SC does not require an additional initial load.
>

?? I was only talking about cmpxchg

> (2) CMPXCHG does an implicit load; how else can it compare?
>

Read Russell's posts. He points out that most usages of cmpxchg
will require an additional load compared with an llsc in order to
find the value to work on.

cmpxchg(lock, UNLOCKED, LOCKED)

does not (although it may still require an extra branch).

--
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com