diff options
author | Pierre Peiffer <pierre.peiffer@bull.net> | 2007-05-09 05:35:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-09 15:30:55 -0400 |
commit | d0aa7a70bf03b9de9e995ab272293be1f7937822 (patch) | |
tree | 194b30b7b8374b946f166996cb99fb95eb3b7819 /kernel/rtmutex_common.h | |
parent | c19384b5b296905d4988c7c684ff540a0f9d65be (diff) |
futex_requeue_pi optimization
This patch provides the futex_requeue_pi functionality, which allows some
threads waiting on a normal futex to be requeued on the wait-queue of a
PI-futex.
This provides an optimization, already used for (normal) futexes, to be used
with the PI-futexes.
This optimization is currently used by the glibc in pthread_broadcast, when
using "normal" mutexes. With futex_requeue_pi, it can be used with
PRIO_INHERIT mutexes too.
Signed-off-by: Pierre Peiffer <pierre.peiffer@bull.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Ulrich Drepper <drepper@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/rtmutex_common.h')
-rw-r--r-- | kernel/rtmutex_common.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/kernel/rtmutex_common.h b/kernel/rtmutex_common.h index 9c75856e791e..242ec7ee740b 100644 --- a/kernel/rtmutex_common.h +++ b/kernel/rtmutex_common.h | |||
@@ -113,6 +113,29 @@ static inline unsigned long rt_mutex_owner_pending(struct rt_mutex *lock) | |||
113 | } | 113 | } |
114 | 114 | ||
115 | /* | 115 | /* |
116 | * We can speed up the acquire/release, if the architecture | ||
117 | * supports cmpxchg and if there's no debugging state to be set up | ||
118 | */ | ||
119 | #if defined(__HAVE_ARCH_CMPXCHG) && !defined(CONFIG_DEBUG_RT_MUTEXES) | ||
120 | # define rt_mutex_cmpxchg(l,c,n) (cmpxchg(&l->owner, c, n) == c) | ||
121 | static inline void mark_rt_mutex_waiters(struct rt_mutex *lock) | ||
122 | { | ||
123 | unsigned long owner, *p = (unsigned long *) &lock->owner; | ||
124 | |||
125 | do { | ||
126 | owner = *p; | ||
127 | } while (cmpxchg(p, owner, owner | RT_MUTEX_HAS_WAITERS) != owner); | ||
128 | } | ||
129 | #else | ||
130 | # define rt_mutex_cmpxchg(l,c,n) (0) | ||
131 | static inline void mark_rt_mutex_waiters(struct rt_mutex *lock) | ||
132 | { | ||
133 | lock->owner = (struct task_struct *) | ||
134 | ((unsigned long)lock->owner | RT_MUTEX_HAS_WAITERS); | ||
135 | } | ||
136 | #endif | ||
137 | |||
138 | /* | ||
116 | * PI-futex support (proxy locking functions, etc.): | 139 | * PI-futex support (proxy locking functions, etc.): |
117 | */ | 140 | */ |
118 | extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock); | 141 | extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock); |
@@ -120,4 +143,15 @@ extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock, | |||
120 | struct task_struct *proxy_owner); | 143 | struct task_struct *proxy_owner); |
121 | extern void rt_mutex_proxy_unlock(struct rt_mutex *lock, | 144 | extern void rt_mutex_proxy_unlock(struct rt_mutex *lock, |
122 | struct task_struct *proxy_owner); | 145 | struct task_struct *proxy_owner); |
146 | |||
147 | extern void rt_mutex_set_owner(struct rt_mutex *lock, struct task_struct *owner, | ||
148 | unsigned long mask); | ||
149 | extern void __rt_mutex_adjust_prio(struct task_struct *task); | ||
150 | extern int rt_mutex_adjust_prio_chain(struct task_struct *task, | ||
151 | int deadlock_detect, | ||
152 | struct rt_mutex *orig_lock, | ||
153 | struct rt_mutex_waiter *orig_waiter, | ||
154 | struct task_struct *top_task); | ||
155 | extern void remove_waiter(struct rt_mutex *lock, | ||
156 | struct rt_mutex_waiter *waiter); | ||
123 | #endif | 157 | #endif |