lkml.org 
[lkml]   [2005]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
Date
Nick Piggin <nickpiggin@yahoo.com.au> wrote:

> Yes, the architecture code knows whether or not it implements atomic ops
> with spinlocks, so that architecture is in the position to decide to override
> the mutex implementation. *generic* code shouldn't worry about that, it should
> use the interfaces available, and if that isn't optimal on some architecture
> then that architecture can override it.

However, a number of generic templates can be provided if it makes things
easier for the arches because all they need to is:

[arch/wibble/Kconfig]
config MUTEX_TYPE_FOO
bool
default y

[include/asm-wibble/system.h]
#define __mutex_foo_this() { ... }
#define __mutex_foo_that() { ... }

The unconditional two-state exchange I think will be a useful template for a
number of archs that don't have anything more advanced than XCHG/TAS/BSET/SWAP.

> 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.

> and not do the additional initial load to prime the cmpxchg.

Two points:

(1) LL/SC does not require an additional initial load.

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

LL/SC can never be worse than CMPXCHG, if only because you're very unlikely to
have both, but it can be better.

David
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-12-16 16:56    [W:0.193 / U:0.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site