@@ -1726,12 +1726,33 @@ void rt_mutex_proxy_unlock(struct rt_mutex *lock,
1726
1726
rt_mutex_set_owner (lock , NULL );
1727
1727
}
1728
1728
1729
+ /**
1730
+ * __rt_mutex_start_proxy_lock() - Start lock acquisition for another task
1731
+ * @lock: the rt_mutex to take
1732
+ * @waiter: the pre-initialized rt_mutex_waiter
1733
+ * @task: the task to prepare
1734
+ *
1735
+ * Starts the rt_mutex acquire; it enqueues the @waiter and does deadlock
1736
+ * detection. It does not wait, see rt_mutex_wait_proxy_lock() for that.
1737
+ *
1738
+ * NOTE: does _NOT_ remove the @waiter on failure; must either call
1739
+ * rt_mutex_wait_proxy_lock() or rt_mutex_cleanup_proxy_lock() after this.
1740
+ *
1741
+ * Returns:
1742
+ * 0 - task blocked on lock
1743
+ * 1 - acquired the lock for task, caller should wake it up
1744
+ * <0 - error
1745
+ *
1746
+ * Special API call for PI-futex support.
1747
+ */
1729
1748
int __rt_mutex_start_proxy_lock (struct rt_mutex * lock ,
1730
1749
struct rt_mutex_waiter * waiter ,
1731
1750
struct task_struct * task )
1732
1751
{
1733
1752
int ret ;
1734
1753
1754
+ lockdep_assert_held (& lock -> wait_lock );
1755
+
1735
1756
if (try_to_take_rt_mutex (lock , task , NULL ))
1736
1757
return 1 ;
1737
1758
@@ -1749,9 +1770,6 @@ int __rt_mutex_start_proxy_lock(struct rt_mutex *lock,
1749
1770
ret = 0 ;
1750
1771
}
1751
1772
1752
- if (unlikely (ret ))
1753
- remove_waiter (lock , waiter );
1754
-
1755
1773
debug_rt_mutex_print_deadlock (waiter );
1756
1774
1757
1775
return ret ;
@@ -1763,12 +1781,18 @@ int __rt_mutex_start_proxy_lock(struct rt_mutex *lock,
1763
1781
* @waiter: the pre-initialized rt_mutex_waiter
1764
1782
* @task: the task to prepare
1765
1783
*
1784
+ * Starts the rt_mutex acquire; it enqueues the @waiter and does deadlock
1785
+ * detection. It does not wait, see rt_mutex_wait_proxy_lock() for that.
1786
+ *
1787
+ * NOTE: unlike __rt_mutex_start_proxy_lock this _DOES_ remove the @waiter
1788
+ * on failure.
1789
+ *
1766
1790
* Returns:
1767
1791
* 0 - task blocked on lock
1768
1792
* 1 - acquired the lock for task, caller should wake it up
1769
1793
* <0 - error
1770
1794
*
1771
- * Special API call for FUTEX_REQUEUE_PI support.
1795
+ * Special API call for PI-futex support.
1772
1796
*/
1773
1797
int rt_mutex_start_proxy_lock (struct rt_mutex * lock ,
1774
1798
struct rt_mutex_waiter * waiter ,
@@ -1778,6 +1802,8 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
1778
1802
1779
1803
raw_spin_lock_irq (& lock -> wait_lock );
1780
1804
ret = __rt_mutex_start_proxy_lock (lock , waiter , task );
1805
+ if (unlikely (ret ))
1806
+ remove_waiter (lock , waiter );
1781
1807
raw_spin_unlock_irq (& lock -> wait_lock );
1782
1808
1783
1809
return ret ;
@@ -1845,7 +1871,8 @@ int rt_mutex_wait_proxy_lock(struct rt_mutex *lock,
1845
1871
* @lock: the rt_mutex we were woken on
1846
1872
* @waiter: the pre-initialized rt_mutex_waiter
1847
1873
*
1848
- * Attempt to clean up after a failed rt_mutex_wait_proxy_lock().
1874
+ * Attempt to clean up after a failed __rt_mutex_start_proxy_lock() or
1875
+ * rt_mutex_wait_proxy_lock().
1849
1876
*
1850
1877
* Unless we acquired the lock; we're still enqueued on the wait-list and can
1851
1878
* in fact still be granted ownership until we're removed. Therefore we can
0 commit comments