include/linux/rtmutex.h | 5 +++++ kernel/rtmutex.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) Index: linux-futex.q/include/linux/rtmutex.h =================================================================== --- linux-futex.q.orig/include/linux/rtmutex.h +++ linux-futex.q/include/linux/rtmutex.h @@ -110,6 +110,11 @@ extern int fastcall rt_mutex_trylock(str extern void fastcall rt_mutex_unlock(struct rt_mutex *lock); +/* Futex support functions. Do not use otherwise ! */ +extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock); +extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock, + struct task_struct *proxy_owner); + #ifdef CONFIG_RT_MUTEXES # define rt_mutex_init_task(p) \ do { \ Index: linux-futex.q/kernel/rtmutex.c =================================================================== --- linux-futex.q.orig/kernel/rtmutex.c +++ linux-futex.q/kernel/rtmutex.c @@ -679,3 +679,42 @@ void fastcall __rt_mutex_init(struct rt_ debug_rt_mutex_init(lock, name); } EXPORT_SYMBOL_GPL(__rt_mutex_init); + +/** + * rt_mutex_init_proxy_locked - initialize and lock a rt_mutex on behalf of a + * proxy owner + * + * @lock: the rt_mutex to be locked + * @proxy_owner:the task to set as owner + * + * No locking. Caller has to do serializing itself + * Special API call for PI-futex support + */ +void rt_mutex_init_proxy_locked(struct rt_mutex *lock, + struct task_struct *proxy_owner) +{ + __rt_mutex_init(lock, NULL); + debug_rt_mutex_lock(lock __RET_IP__); + rt_mutex_set_owner(lock, proxy_owner, 0); + rt_mutex_deadlock_account_lock(lock, proxy_owner); +} + +/** + * rt_mutex_next_owner - return the next owner of the lock + * + * @lock: the rt lock query + * + * Returns the next owner of the lock or NULL + * + * Caller has to serialize against other accessors to the lock + * itself. + * + * Special API call for PI-futex support + */ +struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock) +{ + if (!rt_mutex_has_waiters(lock)) + return NULL; + + return rt_mutex_first_waiter(lock)->task; +}