Commit 0cdbee9920fb37eb2dc49b860c2b28862d647adc

Authored by Ingo Molnar
Committed by Linus Torvalds
1 parent 61a8712286

[PATCH] pi-futex: rt mutex futex api

Add proxy-locking rt-mutex functionality needed by pi-futexes.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 55 additions and 0 deletions Side-by-side Diff

... ... @@ -903,4 +903,59 @@
903 903 debug_rt_mutex_init(lock, name);
904 904 }
905 905 EXPORT_SYMBOL_GPL(__rt_mutex_init);
  906 +
  907 +/**
  908 + * rt_mutex_init_proxy_locked - initialize and lock a rt_mutex on behalf of a
  909 + * proxy owner
  910 + *
  911 + * @lock: the rt_mutex to be locked
  912 + * @proxy_owner:the task to set as owner
  913 + *
  914 + * No locking. Caller has to do serializing itself
  915 + * Special API call for PI-futex support
  916 + */
  917 +void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
  918 + struct task_struct *proxy_owner)
  919 +{
  920 + __rt_mutex_init(lock, NULL);
  921 + debug_rt_mutex_proxy_lock(lock, proxy_owner __RET_IP__);
  922 + rt_mutex_set_owner(lock, proxy_owner, 0);
  923 + rt_mutex_deadlock_account_lock(lock, proxy_owner);
  924 +}
  925 +
  926 +/**
  927 + * rt_mutex_proxy_unlock - release a lock on behalf of owner
  928 + *
  929 + * @lock: the rt_mutex to be locked
  930 + *
  931 + * No locking. Caller has to do serializing itself
  932 + * Special API call for PI-futex support
  933 + */
  934 +void rt_mutex_proxy_unlock(struct rt_mutex *lock,
  935 + struct task_struct *proxy_owner)
  936 +{
  937 + debug_rt_mutex_proxy_unlock(lock);
  938 + rt_mutex_set_owner(lock, NULL, 0);
  939 + rt_mutex_deadlock_account_unlock(proxy_owner);
  940 +}
  941 +
  942 +/**
  943 + * rt_mutex_next_owner - return the next owner of the lock
  944 + *
  945 + * @lock: the rt lock query
  946 + *
  947 + * Returns the next owner of the lock or NULL
  948 + *
  949 + * Caller has to serialize against other accessors to the lock
  950 + * itself.
  951 + *
  952 + * Special API call for PI-futex support
  953 + */
  954 +struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock)
  955 +{
  956 + if (!rt_mutex_has_waiters(lock))
  957 + return NULL;
  958 +
  959 + return rt_mutex_top_waiter(lock)->task;
  960 +}