mutex subsystem, -V5
cover mutex subsystem, -V5
this is verion -V5 of the generic mutex subsystem. It consists of the following patches:
add-atomic-xchg.patch
add-atomic-call-func-i386.patch
add-atomic-call-func-x86_64.patch
add-atomic-call-wrappers-rest.patch
mutex-core.patch
mutex-docs.patch
mutex-switch-arm-to-xchg.patch
mutex-debug.patch
mutex-debug-more.patch
xfs-mutex-namespace-collision-fix.patch
the patches are against Linus' latest GIT tree, and they should work fine on every Linux architecture.
Changes since -V4:
26 files changed, 255 insertions(+), 104 deletions(-)
- added Documentation/mutex-design.txt, suggested by Andrew Morton.
- removed __ARCH_WANT_XCHG_BASED_ATOMICS and implemented CONFIG_MUTEX_XCHG_ALGORITHM instead, based on comments from Christoph Hellwig.
- updated ARM to use CONFIG_MUTEX_XCHG_ALGORITHM.
- added mutex_destroy(), suggested by Christoph Hellwig.
- added queue-secondary-waiters-as-LIFO, suggested by Nick Piggin.
- mutex.h: include file ordering fix (Christoph Hellwig).
- mutex.h: comment fix (Christoph Hellwig).
- mutex.c: smaller cleanups
Ingo
Quoted 7 lines · Ingo Molnar
Changes since -V4:
- removed
__ARCH_WANT_XCHG_BASED_ATOMICSand implementedCONFIG_MUTEX_XCHG_ALGORITHMinstead, based on comments from Christoph Hellwig.- updated ARM to use
CONFIG_MUTEX_XCHG_ALGORITHM.
This is still not what I'd like to see, per my previous comments.
Do you have any strong reason for pursuing that route instead of going with my suggested approach?
Nicolas
Quoted 8 lines · Nicolas Pitre
Quoted 6 lines · Ingo Molnar
Changes since -V4:
- removed
__ARCH_WANT_XCHG_BASED_ATOMICSand implementedCONFIG_MUTEX_XCHG_ALGORITHMinstead, based on comments from Christoph Hellwig.
Quoted 6 lines
Quoted 1 line
- updated ARM to use
CONFIG_MUTEX_XCHG_ALGORITHM.This is still not what I'd like to see, per my previous comments.
Do you have any strong reason for pursuing that route instead of going with my suggested approach?
I'd just prefer a
<asm-generic/mutex-xchg-algo.h>
and then any architecture can do whatever they damn well want, and anybody who doesn't want to, can just include that header file.
No #ifdef's, no config options, no "generic fallback". Just unconditionally do the sane thing.
I'm with whoever HATES those stupid __ARCH_xxx #defines. It's a sign of bad design. Either it's a generic algorithm (and it can be in <asm-generic> or it's not). In no case should we ever have __ARCH_HAS_xxx (and yes, that includes cases where we _currently_ use __ARCH_HAS_xxx).
Linus
Quoted 24 lines · Linus Torvalds
Quoted 8 lines · Nicolas Pitre
Quoted 6 lines · Ingo Molnar
Changes since -V4:
- removed
__ARCH_WANT_XCHG_BASED_ATOMICSand implementedCONFIG_MUTEX_XCHG_ALGORITHMinstead, based on comments from Christoph Hellwig.Quoted 6 lines
Quoted 1 line
- updated ARM to use
CONFIG_MUTEX_XCHG_ALGORITHM.This is still not what I'd like to see, per my previous comments.
Do you have any strong reason for pursuing that route instead of going with my suggested approach?
I'd just prefer a
<
asm-generic/mutex-xchg-algo.h>and then any architecture can do whatever they damn well want, and anybody who doesn't want to, can just include that header file.
Quoted 7 lines
No #ifdef's, no config options, no "generic fallback". Just unconditionally do the sane thing.
I'm with whoever HATES those stupid
__ARCH_xxx#defines. It's a sign of bad design. Either it's a generic algorithm (and it can be in <asm-generic> or it's not). In no case should we ever have__ARCH_HAS_xxx(and yes, that includes cases where we _currently_ use__ARCH_HAS_xxx).
Isnt there some other way to make all of this much easier to modify? Both the arch specific and the generic layers?
There are definitely arch specific improvements but there are also possible ways that the generic way of locking can be improved. Some of these may require changing the data structures.
F.e. I know a couple of architectures (embedded as well as different varieties of NUMA) that have special memory areas for locks that bypass the bus protocols in order to realize more efficient locking.
Large NUMA systems with lots of lock contention benefit if the one trying to lock backs off for awhile. This is first of all a modification of the contention path. However, one could also want to locally block multiple lock attempts coming from the same node in order to reduce contention on the NUMA interlink. See also my HBO proposal
http://marc.theaimsgroup.com/?l=linux-kernel&m=111696945030791&w=2
I would like some more flexible way of dealing with locks in general. The code for the MUTEXes seems to lock us into a specific way of realizing locks again.
Quoted 3 lines · Christoph Lameter
I would like some more flexible way of dealing with locks in general. The code for the MUTEXes seems to lock us into a specific way of realizing locks again.
Yes, and that's what I'm attempting to prevent.
The low-level locking mechanism for mutexes needs to have the weakest (and simplest) semantics possible without compromising the generic code from doing its job. Setting on a strict pure atomic decrement (the strictest semantic) or an atomic swap (better but still a tiny bit stricter than necessary) is not required for proper mutex support with the current core code.
Nicolas
Quoted 11 lines · Christoph Lameter
Large NUMA systems with lots of lock contention benefit if the one trying to lock backs off for awhile. This is first of all a modification of the contention path. However, one could also want to locally block multiple lock attempts coming from the same node in order to reduce contention on the NUMA interlink. See also my HBO proposal
http://marc.theaimsgroup.com/?l=linux-kernel&m=111696945030791&w=2I would like some more flexible way of dealing with locks in general. The code for the MUTEXes seems to lock us into a specific way of realizing locks again.
yeah, but we should be careful where to put it: the perfect place for most of these features and experiments is in the _generic_ code, not in arch-level code! Look at how we are doing it with spinlocks. It used to be a nightmare that every arch had to implement preempt support, or spinlock debugging support, and they ended up not implementing these features at all, or only doing it partially.
i definitely do not say that _everything_ should be generalized. That would be micromanaging things. But i definitely think there's an unhealthy amount of _under_ generalization in current Linux architectures, and i dont want the mutex subsystem to fall into that trap.
also, lets face it, even most of the lowlevel details do have some generic trends in them. And that's not an accident: it's because everything is controlled by the laws of physics, which tend to be pretty generic and work the same way, no matter which CPU architecture we are on. Yes, there can be oddball architectures, but all in one there's a good reason why we are able to have 90% of the kernel in generic code.
even lowlevel things such as mutexes can be described generally. We need roughly 3 states to implement them. We need ops to transit from one state to another, and to figure out whether that transition succeeded. Now there are CPUs where we can do almost arbitrary math operations cheaply, and can test for sign and zero. For those CPUs the decision is
easy: we use the best math, which results in the best code. For other CPUs we might have to use lesser state transitions, with more side-effects. Certainly an architecture should have a say in determining which transitions are the best ones, but the generic code wants to be able to control the _state_ of the mutex.
What if we want to have a fourth state? [i dont think we want one, but it could happen] What would you prefer - if there were clear rules about what the arch level ops do, or if an architecture defined its rules in assembly, basically hardcoding it and making it impossible to change without changing the assembly? I went for ops that are generic and describe the math, not the implementation.
and look at the end result: we have a 400 lines of mutex.c (half of which is comments) that covers 100% of the architectures, in almost the most optimal way. [with only a few openings left that could reduce an 8 instruction fastpath to a 6 instruction fastpath.] Lets not give that up and make it once again a hard to change thing.
Ingo
Quoted 5 lines · Ingo Molnar
i definitely do not say that _everything_ should be generalized. That would be micromanaging things. But i definitely think there's an unhealthy amount of _under_ generalization in current Linux architectures, and i dont want the mutex subsystem to fall into that trap.
BTW, I strongly believe the semaphore implementation could go with the same model the mutex model I hope is heading for.
I.e., the only thing each architecture really have to implement is __sem_fast_down and __sem_fast _up, and incidentally they would have the exact same definition as your atomic_*_call_if_* functions (while a bit too restrictive for mutex semantics, they really are the minimum required for semaphores). Then all the current per architecture semaphore code could be consolidated.
Nicolas
Quoted 10 lines · Ingo Molnar
Quoted 3 lines
I would like some more flexible way of dealing with locks in general. The code for the MUTEXes seems to lock us into a specific way of realizing locks again.
yeah, but we should be careful where to put it: the perfect place for most of these features and experiments is in the _generic_ code, not in arch-level code! Look at how we are doing it with spinlocks. It used to be a nightmare that every arch had to implement preempt support, or spinlock debugging support, and they ended up not implementing these features at all, or only doing it partially.
I think we need to have the ability to modify things on both levels. There needs to be a way to introduce f.e. a general HBO type locking algorithm for all architectures. But then also a way for an arch to do special things that are strongly depending on a particular arch like relocating the actual storage location of a lock to a specially handled memory area.
Quoted 5 lines
i definitely do not say that _everything_ should be generalized. That would be micromanaging things. But i definitely think there's an unhealthy amount of _under_ generalization in current Linux architectures, and i dont want the mutex subsystem to fall into that trap.
The mutex implementation here is one implementation. There needs to be a generic way to replace this implementation with another in an arch independent way as well as the ability for an arch to modify low level elements necessary to optimize locks on a particular hardware.
Then there is the common ground of low level mutexes with spinlocks. So far spinlocks also work for semaphores. Now with the MUTEXes we have two different locking mechanism that largely overlap in in functionality. In the past one could simply replace the spinlock implementation, now one also has to worry about MUTEXes.
I wish we had some strategy to make all of this easier and gather common elements together.
Quoted 13 lines · Linus Torvalds
Quoted 10 lines · Nicolas Pitre
Quoted 7 lines · Ingo Molnar
Changes since -V4:
- removed
__ARCH_WANT_XCHG_BASED_ATOMICSand implementedCONFIG_MUTEX_XCHG_ALGORITHMinstead, based on comments from Christoph Hellwig.- updated ARM to use
CONFIG_MUTEX_XCHG_ALGORITHM.
Quoted 8 lines
Quoted 4 lines
This is still not what I'd like to see, per my previous comments.
Do you have any strong reason for pursuing that route instead of going with my suggested approach?
I'd just prefer a
<
asm-generic/mutex-xchg-algo.h>
something like this?
(this one is incremental to the patch series; a full one against -rc6 is at http://www.fenrus.org/mutex.patch )
arch/arm/Kconfig +0 -4
@@ -50,10 +50,6 @@ config UID16 bool default y -config MUTEX_XCHG_ALGORITHM - bool - default y - config RWSEM_GENERIC_SPINLOCK bool default y
include/asm-alpha/atomic.h +0 -11
@@ -178,17 +178,6 @@ static __inline__ long atomic64_sub_retu#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-alpha/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-arm/atomic.h +0 -6
@@ -175,12 +175,6 @@ static inline void atomic_clear_mask(uns#endif /* __LINUX_ARM_ARCH__ */ -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(): -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int atomic_add_unless (atomic_t *v,int a,int u)
include/asm-arm/mutex.h +8 -0
@@ -0,0 +1,8 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead +*/ + +#include <asm-generic/mutex-xchg.h>
include/asm-arm26/atomic.h +0 -11
@@ -76,17 +76,6 @@ static inline int atomic_cmpxchg(atomic_return ret; } -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int atomic_add_unless (atomic_t *v,int a,int u)
include/asm-arm26/mutex.h +8 -0
@@ -0,0 +1,8 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead +*/ + +#include <asm-generic/mutex-xchg.h>
include/asm-cris/atomic.h +0 -11
@@ -136,17 +136,6 @@ static inline int atomic_cmpxchg(atomic_return ret; } -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int atomic_add_unless (atomic_t *v,int a,int u)
include/asm-cris/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-frv/atomic.h +0 -11
@@ -417,17 +417,6 @@ extern uint32_t __cmpxchg_32(uint32_t *v#define atomic_cmpxchg (v, old, new) ((int)cmpxchg(&((v)->counter), old, new))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-frv/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-generic/atomic-call-if.h +0 -37
@@ -1,37 +0,0 @@ -/* -* asm-generic/atomic-call-if.h -* -* Generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(), based on atomic_dec_return() -* and atomic_inc_return(). -*/ -#ifndef _ASM_GENERIC_ATOMIC_CALL_IF_H -#define _ASM_GENERIC_ATOMIC_CALL_IF_H - -/** -* atomic_dec_call_if_negative - decrement and call function if negative -* @v: pointer of type atomic_t -* @fn: function to call if the result is negative -* -* Atomically decrements @v and calls a function if the result is negative. -*/ -#define atomic_dec_call_if_negative (v, fn_name) \ -do { \ - if (atomic_dec_return(v) < 0) \ - fn_name(v); \ -} while (0) - -/** -* atomic_inc_call_if_nonpositive - increment and call function if nonpositive -* @v: pointer of type atomic_t -* @fn: function to call if the result is nonpositive -* -* Atomically increments @v and calls a function if the result is nonpositive. -*/ -#define atomic_inc_call_if_nonpositive (v, fn_name) \ -do { \ - if (atomic_inc_return(v) <= 0) \ - fn_name(v); \ -} while (0) - -#endif
include/asm-generic/mutex-dec.h +66 -0
66 lines not on this page · raw message
include/asm-generic/mutex-xchg.h +70 -0
70 lines not on this page · raw message
include/asm-h8300/atomic.h +0 -13
@@ -95,19 +95,6 @@ static inline int atomic_cmpxchg(atomic_return ret; } -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> - -#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -static inline int atomic_add_unless (atomic_t *v,int a,int u) {int ret;
include/asm-h8300/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-i386/atomic.h +0 -57
63 lines not on this page · raw message
include/asm-i386/mutex.h +96 -0
96 lines not on this page · raw message
include/asm-ia64/atomic.h +0 -11
@@ -91,17 +91,6 @@ ia64_atomic64_sub (__s64 i, atomic64_t *#define atomic_cmpxchg (v, old, new) ((int)cmpxchg(&((v)->counter), old, new))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-ia64/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-m32r/atomic.h +0 -11
@@ -245,17 +245,6 @@ static __inline__ int atomic_dec_return(#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -/** * atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t
include/asm-m32r/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-m68k/atomic.h +0 -11
@@ -142,17 +142,6 @@ static inline void atomic_set_mask(unsig#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-m68k/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-m68knommu/atomic.h +0 -11
@@ -131,17 +131,6 @@ static inline int atomic_sub_return(int#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-m68knommu/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-mips/atomic.h +0 -11
@@ -291,17 +291,6 @@ static __inline__ int atomic_sub_if_posi#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -/** * atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t
include/asm-mips/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-parisc/atomic.h +0 -11
@@ -167,17 +167,6 @@ static __inline__ int atomic_read(const#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -/** * atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t
include/asm-parisc/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-powerpc/atomic.h +0 -11
@@ -121,17 +121,6 @@ static __inline__ int atomic_inc_return( }/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> - -/* * atomic_inc_and_test - increment and test * @v: pointer of type atomic_t *
include/asm-powerpc/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-s390/atomic.h +0 -11
@@ -201,17 +201,6 @@ atomic_compare_and_swap(int expected_old#define atomic_cmpxchg (v, o, n) (atomic_compare_and_swap((o), (n), &((v)->counter)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-s390/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-sh/atomic.h +0 -11
@@ -101,17 +101,6 @@ static inline int atomic_cmpxchg(atomic_return ret; } -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int atomic_add_unless (atomic_t *v,int a,int u)
include/asm-sh/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-sh64/atomic.h +0 -11
@@ -113,17 +113,6 @@ static inline int atomic_cmpxchg(atomic_return ret; } -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int atomic_add_unless (atomic_t *v,int a,int u)
include/asm-sh64/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-sparc/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-sparc64/atomic.h +0 -11
@@ -74,17 +74,6 @@ extern int atomic64_sub_ret(int, atomic6#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-sparc64/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-um/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-v850/atomic.h +0 -11
@@ -104,17 +104,6 @@ static inline int atomic_cmpxchg(atomic_return ret; } -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int atomic_add_unless (atomic_t *v,int a,int u)
include/asm-v850/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
include/asm-x86_64/atomic.h +0 -58
64 lines not on this page · raw message
include/asm-x86_64/mutex.h +69 -0
69 lines not on this page · raw message
include/asm-xtensa/atomic.h +0 -11
@@ -226,17 +226,6 @@ static inline int atomic_sub_return(int#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -/* -* Pull in the generic wrappers for atomic_dec_call_if_negative() and -* atomic_inc_call_if_nonpositive(). -* -* TODO: implement optimized primitives instead, or leave the generic -* implementation in place, or enable CONFIG_MUTEX_XCHG_ALGORITHM -* to tell the generic mutex code to use the atomic_xchg() based -* fastpath implementation. -*/ -#include <asm-generic/atomic-call-if.h> -/** * atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t
include/asm-xtensa/mutex.h +10 -0
@@ -0,0 +1,10 @@ +/* +* Pull in the generic wrappers for __mutex_fastpath_lock() and +* __mutex_fastpath_unlock(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based +* generic implementation. +*/ + +#include <asm-generic/mutex-dec.h>
kernel/mutex.c +15 -37
84 lines not on this page · raw message
Quoted 4 lines · Arjan van de Ven
something like this?
(this one is incremental to the patch series; a full one against -rc6 is at http://www.fenrus.org/mutex.patch )
thanks - i've integrated this into the -V6 version (which i released shortly ago).
Ingo
Ingo,
Are you updating your http://redhat.com/~mingo/generic-mutex-subsystem/
with every release. And if so (like you need more work ;) could you have some way to know which version its at?
Thanks,
-- Steve