Lines Matching full:lock
34 struct rt_mutex *lock, in __ww_mutex_add_waiter() argument
40 static inline void __ww_mutex_check_waiters(struct rt_mutex *lock, in __ww_mutex_check_waiters() argument
45 static inline void ww_mutex_lock_acquired(struct ww_mutex *lock, in ww_mutex_lock_acquired() argument
50 static inline int __ww_mutex_check_kill(struct rt_mutex *lock, in __ww_mutex_check_kill() argument
64 * lock->owner state tracking:
66 * lock->owner holds the task_struct pointer of the owner. Bit 0
67 * is used to keep track of the "lock has waiters" state.
70 * NULL 0 lock is free (fast acquire possible)
71 * NULL 1 lock is free and has waiters and the top waiter
72 * is going to take the lock*
73 * taskpointer 0 lock is held (fast release possible)
74 * taskpointer 1 lock is held and has waiters**
77 * possible when bit 0 of lock->owner is 0.
79 * (*) It also can be a transitional state when grabbing the lock
80 * with ->wait_lock is held. To prevent any fast path cmpxchg to the lock,
81 * we need to set the bit0 before looking at the lock, and the owner may be
85 * waiters. This can happen when grabbing the lock in the slow path.
86 * To prevent a cmpxchg of the owner releasing the lock, we need to
87 * set this bit before looking at the lock.
91 rt_mutex_set_owner(struct rt_mutex_base *lock, struct task_struct *owner) in rt_mutex_set_owner() argument
95 if (rt_mutex_has_waiters(lock)) in rt_mutex_set_owner()
98 WRITE_ONCE(lock->owner, (struct task_struct *)val); in rt_mutex_set_owner()
101 static __always_inline void clear_rt_mutex_waiters(struct rt_mutex_base *lock) in clear_rt_mutex_waiters() argument
103 lock->owner = (struct task_struct *) in clear_rt_mutex_waiters()
104 ((unsigned long)lock->owner & ~RT_MUTEX_HAS_WAITERS); in clear_rt_mutex_waiters()
107 static __always_inline void fixup_rt_mutex_waiters(struct rt_mutex_base *lock) in fixup_rt_mutex_waiters() argument
109 unsigned long owner, *p = (unsigned long *) &lock->owner; in fixup_rt_mutex_waiters()
111 if (rt_mutex_has_waiters(lock)) in fixup_rt_mutex_waiters()
116 * lock->owner still has the waiters bit set, otherwise the in fixup_rt_mutex_waiters()
122 * lock(l->lock) in fixup_rt_mutex_waiters()
126 * unlock(l->lock) in fixup_rt_mutex_waiters()
130 * lock(l->lock) in fixup_rt_mutex_waiters()
134 * unlock(l->lock) in fixup_rt_mutex_waiters()
137 * lock(l->lock) in fixup_rt_mutex_waiters()
140 * unlock(l->lock) in fixup_rt_mutex_waiters()
141 * lock(l->lock) in fixup_rt_mutex_waiters()
145 * unlock(l->lock) in fixup_rt_mutex_waiters()
146 * lock(l->lock) in fixup_rt_mutex_waiters()
153 * lock(l->lock) in fixup_rt_mutex_waiters()
166 * serialized by l->lock, so nothing else can modify the waiters in fixup_rt_mutex_waiters()
182 static __always_inline bool rt_mutex_cmpxchg_acquire(struct rt_mutex_base *lock, in rt_mutex_cmpxchg_acquire() argument
186 return try_cmpxchg_acquire(&lock->owner, &old, new); in rt_mutex_cmpxchg_acquire()
189 static __always_inline bool rt_mutex_cmpxchg_release(struct rt_mutex_base *lock, in rt_mutex_cmpxchg_release() argument
193 return try_cmpxchg_release(&lock->owner, &old, new); in rt_mutex_cmpxchg_release()
198 * all future threads that attempt to [Rmw] the lock to the slowpath. As such
201 static __always_inline void mark_rt_mutex_waiters(struct rt_mutex_base *lock) in mark_rt_mutex_waiters() argument
203 unsigned long owner, *p = (unsigned long *) &lock->owner; in mark_rt_mutex_waiters()
214 * 2) Drop lock->wait_lock
215 * 3) Try to unlock the lock with cmpxchg
217 static __always_inline bool unlock_rt_mutex_safe(struct rt_mutex_base *lock, in unlock_rt_mutex_safe() argument
219 __releases(lock->wait_lock) in unlock_rt_mutex_safe()
221 struct task_struct *owner = rt_mutex_owner(lock); in unlock_rt_mutex_safe()
223 clear_rt_mutex_waiters(lock); in unlock_rt_mutex_safe()
224 raw_spin_unlock_irqrestore(&lock->wait_lock, flags); in unlock_rt_mutex_safe()
230 * lock(wait_lock); in unlock_rt_mutex_safe()
232 * mark_rt_mutex_waiters(lock); in unlock_rt_mutex_safe()
233 * acquire(lock); in unlock_rt_mutex_safe()
237 * lock(wait_lock); in unlock_rt_mutex_safe()
238 * mark_rt_mutex_waiters(lock); in unlock_rt_mutex_safe()
243 * lock(wait_lock); in unlock_rt_mutex_safe()
246 * lock(wait_lock); in unlock_rt_mutex_safe()
247 * acquire(lock); in unlock_rt_mutex_safe()
249 return rt_mutex_cmpxchg_release(lock, owner, NULL); in unlock_rt_mutex_safe()
253 static __always_inline bool rt_mutex_cmpxchg_acquire(struct rt_mutex_base *lock, in rt_mutex_cmpxchg_acquire() argument
261 static __always_inline bool rt_mutex_cmpxchg_release(struct rt_mutex_base *lock, in rt_mutex_cmpxchg_release() argument
268 static __always_inline void mark_rt_mutex_waiters(struct rt_mutex_base *lock) in mark_rt_mutex_waiters() argument
270 lock->owner = (struct task_struct *) in mark_rt_mutex_waiters()
271 ((unsigned long)lock->owner | RT_MUTEX_HAS_WAITERS); in mark_rt_mutex_waiters()
275 * Simple slow path only version: lock->owner is protected by lock->wait_lock.
277 static __always_inline bool unlock_rt_mutex_safe(struct rt_mutex_base *lock, in unlock_rt_mutex_safe() argument
279 __releases(lock->wait_lock) in unlock_rt_mutex_safe()
281 lock->owner = NULL; in unlock_rt_mutex_safe()
282 raw_spin_unlock_irqrestore(&lock->wait_lock, flags); in unlock_rt_mutex_safe()
396 rt_mutex_enqueue(struct rt_mutex_base *lock, struct rt_mutex_waiter *waiter) in rt_mutex_enqueue() argument
398 rb_add_cached(&waiter->tree_entry, &lock->waiters, __waiter_less); in rt_mutex_enqueue()
402 rt_mutex_dequeue(struct rt_mutex_base *lock, struct rt_mutex_waiter *waiter) in rt_mutex_dequeue() argument
407 rb_erase_cached(&waiter->tree_entry, &lock->waiters); in rt_mutex_dequeue()
501 return p->pi_blocked_on ? p->pi_blocked_on->lock : NULL; in task_blocked_on_lock()
516 * comparison to detect lock chain changes.
545 * [1] lock(task->pi_lock); [R] acquire [P]
548 * [4] lock = waiter->lock; [P]
549 * [5] if (!try_lock(lock->wait_lock)) { [P] try to acquire [L]
554 * [7] requeue_lock_waiter(lock, waiter); [P] + [L]
558 * [10] task = owner(lock); [L]
560 * lock(task->pi_lock); [L] acquire [P]
561 * [11] requeue_pi_waiter(tsk, waiters(lock));[P] + [L]
564 * unlock(lock->wait_lock); release [L]
577 struct rt_mutex_base *lock; in rt_mutex_adjust_prio_chain() local
591 * We limit the lock chain length for each invocation. in rt_mutex_adjust_prio_chain()
602 printk(KERN_WARNING "Maximum lock depth %d reached " in rt_mutex_adjust_prio_chain()
642 * the previous owner of the lock might have released the lock. in rt_mutex_adjust_prio_chain()
649 * the task might have moved on in the lock chain or even left in rt_mutex_adjust_prio_chain()
650 * the chain completely and blocks now on an unrelated lock or in rt_mutex_adjust_prio_chain()
653 * We stored the lock on which @task was blocked in @next_lock, in rt_mutex_adjust_prio_chain()
656 if (next_lock != waiter->lock) in rt_mutex_adjust_prio_chain()
660 * There could be 'spurious' loops in the lock graph due to ww_mutex, in rt_mutex_adjust_prio_chain()
721 * [4] Get the next lock in rt_mutex_adjust_prio_chain()
723 lock = waiter->lock; in rt_mutex_adjust_prio_chain()
726 * which is the reverse lock order versus the other rtmutex in rt_mutex_adjust_prio_chain()
729 if (!raw_spin_trylock(&lock->wait_lock)) { in rt_mutex_adjust_prio_chain()
737 * lock->wait_lock. in rt_mutex_adjust_prio_chain()
739 * Deadlock detection. If the lock is the same as the original in rt_mutex_adjust_prio_chain()
740 * lock which caused us to walk the lock chain or if the in rt_mutex_adjust_prio_chain()
741 * current lock is owned by the task which initiated the chain in rt_mutex_adjust_prio_chain()
744 if (lock == orig_lock || rt_mutex_owner(lock) == top_task) { in rt_mutex_adjust_prio_chain()
759 raw_spin_unlock(&lock->wait_lock); in rt_mutex_adjust_prio_chain()
764 * If we just follow the lock chain for deadlock detection, no in rt_mutex_adjust_prio_chain()
777 * [9] check_exit_conditions_3 protected by lock->wait_lock. in rt_mutex_adjust_prio_chain()
778 * If there is no owner of the lock, end of chain. in rt_mutex_adjust_prio_chain()
780 if (!rt_mutex_owner(lock)) { in rt_mutex_adjust_prio_chain()
781 raw_spin_unlock_irq(&lock->wait_lock); in rt_mutex_adjust_prio_chain()
785 /* [10] Grab the next task, i.e. owner of @lock */ in rt_mutex_adjust_prio_chain()
786 task = get_task_struct(rt_mutex_owner(lock)); in rt_mutex_adjust_prio_chain()
799 top_waiter = rt_mutex_top_waiter(lock); in rt_mutex_adjust_prio_chain()
803 raw_spin_unlock_irq(&lock->wait_lock); in rt_mutex_adjust_prio_chain()
813 * operation on @lock. We need it for the boost/deboost in rt_mutex_adjust_prio_chain()
816 prerequeue_top_waiter = rt_mutex_top_waiter(lock); in rt_mutex_adjust_prio_chain()
818 /* [7] Requeue the waiter in the lock waiter tree. */ in rt_mutex_adjust_prio_chain()
819 rt_mutex_dequeue(lock, waiter); in rt_mutex_adjust_prio_chain()
839 rt_mutex_enqueue(lock, waiter); in rt_mutex_adjust_prio_chain()
846 * [9] check_exit_conditions_3 protected by lock->wait_lock. in rt_mutex_adjust_prio_chain()
848 * We must abort the chain walk if there is no lock owner even in rt_mutex_adjust_prio_chain()
849 * in the dead lock detection case, as we have nothing to in rt_mutex_adjust_prio_chain()
852 if (!rt_mutex_owner(lock)) { in rt_mutex_adjust_prio_chain()
856 * to get the lock. in rt_mutex_adjust_prio_chain()
858 if (prerequeue_top_waiter != rt_mutex_top_waiter(lock)) in rt_mutex_adjust_prio_chain()
860 raw_spin_unlock_irq(&lock->wait_lock); in rt_mutex_adjust_prio_chain()
864 /* [10] Grab the next task, i.e. the owner of @lock */ in rt_mutex_adjust_prio_chain()
865 task = get_task_struct(rt_mutex_owner(lock)); in rt_mutex_adjust_prio_chain()
869 if (waiter == rt_mutex_top_waiter(lock)) { in rt_mutex_adjust_prio_chain()
872 * waiter on the lock. Replace the previous top waiter in rt_mutex_adjust_prio_chain()
882 * The waiter was the top waiter on the lock, but is in rt_mutex_adjust_prio_chain()
892 waiter = rt_mutex_top_waiter(lock); in rt_mutex_adjust_prio_chain()
904 * and lock->wait_lock. The actual decisions are made after we in rt_mutex_adjust_prio_chain()
907 * Check whether the task which owns the current lock is pi in rt_mutex_adjust_prio_chain()
908 * blocked itself. If yes we store a pointer to the lock for in rt_mutex_adjust_prio_chain()
909 * the lock chain change detection above. After we dropped in rt_mutex_adjust_prio_chain()
914 * Store the top waiter of @lock for the end of chain walk in rt_mutex_adjust_prio_chain()
917 top_waiter = rt_mutex_top_waiter(lock); in rt_mutex_adjust_prio_chain()
921 raw_spin_unlock_irq(&lock->wait_lock); in rt_mutex_adjust_prio_chain()
927 * We reached the end of the lock chain. Stop right here. No in rt_mutex_adjust_prio_chain()
934 * If the current waiter is not the top waiter on the lock, in rt_mutex_adjust_prio_chain()
954 * Must be called with lock->wait_lock held and interrupts disabled
956 * @lock: The lock to be acquired.
957 * @task: The task which wants to acquire the lock
958 * @waiter: The waiter that is queued to the lock's wait tree if the
962 try_to_take_rt_mutex(struct rt_mutex_base *lock, struct task_struct *task, in try_to_take_rt_mutex() argument
965 lockdep_assert_held(&lock->wait_lock); in try_to_take_rt_mutex()
968 * Before testing whether we can acquire @lock, we set the in try_to_take_rt_mutex()
969 * RT_MUTEX_HAS_WAITERS bit in @lock->owner. This forces all in try_to_take_rt_mutex()
970 * other tasks which try to modify @lock into the slow path in try_to_take_rt_mutex()
971 * and they serialize on @lock->wait_lock. in try_to_take_rt_mutex()
976 * - There is a lock owner. The caller must fixup the in try_to_take_rt_mutex()
977 * transient state if it does a trylock or leaves the lock in try_to_take_rt_mutex()
980 * - @task acquires the lock and there are no other in try_to_take_rt_mutex()
984 mark_rt_mutex_waiters(lock); in try_to_take_rt_mutex()
987 * If @lock has an owner, give up. in try_to_take_rt_mutex()
989 if (rt_mutex_owner(lock)) in try_to_take_rt_mutex()
994 * into @lock waiter tree. If @waiter == NULL then this is a in try_to_take_rt_mutex()
998 struct rt_mutex_waiter *top_waiter = rt_mutex_top_waiter(lock); in try_to_take_rt_mutex()
1001 * If waiter is the highest priority waiter of @lock, in try_to_take_rt_mutex()
1006 * We can acquire the lock. Remove the waiter from the in try_to_take_rt_mutex()
1007 * lock waiters tree. in try_to_take_rt_mutex()
1009 rt_mutex_dequeue(lock, waiter); in try_to_take_rt_mutex()
1015 * If the lock has waiters already we check whether @task is in try_to_take_rt_mutex()
1016 * eligible to take over the lock. in try_to_take_rt_mutex()
1019 * the lock. @task->pi_blocked_on is NULL, so it does in try_to_take_rt_mutex()
1022 if (rt_mutex_has_waiters(lock)) { in try_to_take_rt_mutex()
1025 rt_mutex_top_waiter(lock))) in try_to_take_rt_mutex()
1030 * don't have to change anything in the lock in try_to_take_rt_mutex()
1035 * No waiters. Take the lock without the in try_to_take_rt_mutex()
1053 * Finish the lock acquisition. @task is the new owner. If in try_to_take_rt_mutex()
1057 if (rt_mutex_has_waiters(lock)) in try_to_take_rt_mutex()
1058 rt_mutex_enqueue_pi(task, rt_mutex_top_waiter(lock)); in try_to_take_rt_mutex()
1066 rt_mutex_set_owner(lock, task); in try_to_take_rt_mutex()
1072 * Task blocks on lock.
1076 * This must be called with lock->wait_lock held and interrupts disabled
1078 static int __sched task_blocks_on_rt_mutex(struct rt_mutex_base *lock, in task_blocks_on_rt_mutex() argument
1084 struct task_struct *owner = rt_mutex_owner(lock); in task_blocks_on_rt_mutex()
1089 lockdep_assert_held(&lock->wait_lock); in task_blocks_on_rt_mutex()
1105 waiter->lock = lock; in task_blocks_on_rt_mutex()
1108 /* Get the top priority waiter on the lock */ in task_blocks_on_rt_mutex()
1109 if (rt_mutex_has_waiters(lock)) in task_blocks_on_rt_mutex()
1110 top_waiter = rt_mutex_top_waiter(lock); in task_blocks_on_rt_mutex()
1111 rt_mutex_enqueue(lock, waiter); in task_blocks_on_rt_mutex()
1121 rtm = container_of(lock, struct rt_mutex, rtmutex); in task_blocks_on_rt_mutex()
1125 rt_mutex_dequeue(lock, waiter); in task_blocks_on_rt_mutex()
1136 if (waiter == rt_mutex_top_waiter(lock)) { in task_blocks_on_rt_mutex()
1147 /* Store the lock on which owner is blocked or NULL */ in task_blocks_on_rt_mutex()
1160 * The owner can't disappear while holding a lock, in task_blocks_on_rt_mutex()
1166 raw_spin_unlock_irq(&lock->wait_lock); in task_blocks_on_rt_mutex()
1168 res = rt_mutex_adjust_prio_chain(owner, chwalk, lock, in task_blocks_on_rt_mutex()
1171 raw_spin_lock_irq(&lock->wait_lock); in task_blocks_on_rt_mutex()
1180 * Called with lock->wait_lock held and interrupts disabled.
1183 struct rt_mutex_base *lock) in mark_wakeup_next_waiter() argument
1189 waiter = rt_mutex_top_waiter(lock); in mark_wakeup_next_waiter()
1203 * queued on the lock until it gets the lock, this lock in mark_wakeup_next_waiter()
1207 * the top waiter can steal this lock. in mark_wakeup_next_waiter()
1209 lock->owner = (void *) RT_MUTEX_HAS_WAITERS; in mark_wakeup_next_waiter()
1226 static int __sched __rt_mutex_slowtrylock(struct rt_mutex_base *lock) in __rt_mutex_slowtrylock() argument
1228 int ret = try_to_take_rt_mutex(lock, current, NULL); in __rt_mutex_slowtrylock()
1231 * try_to_take_rt_mutex() sets the lock waiters bit in __rt_mutex_slowtrylock()
1234 fixup_rt_mutex_waiters(lock); in __rt_mutex_slowtrylock()
1240 * Slow path try-lock function:
1242 static int __sched rt_mutex_slowtrylock(struct rt_mutex_base *lock) in rt_mutex_slowtrylock() argument
1248 * If the lock already has an owner we fail to get the lock. in rt_mutex_slowtrylock()
1249 * This can be done without taking the @lock->wait_lock as in rt_mutex_slowtrylock()
1252 if (rt_mutex_owner(lock)) in rt_mutex_slowtrylock()
1256 * The mutex has currently no owner. Lock the wait lock and try to in rt_mutex_slowtrylock()
1257 * acquire the lock. We use irqsave here to support early boot calls. in rt_mutex_slowtrylock()
1259 raw_spin_lock_irqsave(&lock->wait_lock, flags); in rt_mutex_slowtrylock()
1261 ret = __rt_mutex_slowtrylock(lock); in rt_mutex_slowtrylock()
1263 raw_spin_unlock_irqrestore(&lock->wait_lock, flags); in rt_mutex_slowtrylock()
1268 static __always_inline int __rt_mutex_trylock(struct rt_mutex_base *lock) in __rt_mutex_trylock() argument
1270 if (likely(rt_mutex_cmpxchg_acquire(lock, NULL, current))) in __rt_mutex_trylock()
1273 return rt_mutex_slowtrylock(lock); in __rt_mutex_trylock()
1279 static void __sched rt_mutex_slowunlock(struct rt_mutex_base *lock) in rt_mutex_slowunlock() argument
1285 raw_spin_lock_irqsave(&lock->wait_lock, flags); in rt_mutex_slowunlock()
1287 debug_rt_mutex_unlock(lock); in rt_mutex_slowunlock()
1294 * foo->lock->owner = NULL; in rt_mutex_slowunlock()
1295 * rtmutex_lock(foo->lock); <- fast path in rt_mutex_slowunlock()
1297 * rtmutex_unlock(foo->lock); <- fast path in rt_mutex_slowunlock()
1300 * raw_spin_unlock(foo->lock->wait_lock); in rt_mutex_slowunlock()
1305 * lock->wait_lock. So we do the following sequence: in rt_mutex_slowunlock()
1307 * owner = rt_mutex_owner(lock); in rt_mutex_slowunlock()
1308 * clear_rt_mutex_waiters(lock); in rt_mutex_slowunlock()
1309 * raw_spin_unlock(&lock->wait_lock); in rt_mutex_slowunlock()
1310 * if (cmpxchg(&lock->owner, owner, 0) == owner) in rt_mutex_slowunlock()
1315 * lock->owner is serialized by lock->wait_lock: in rt_mutex_slowunlock()
1317 * lock->owner = NULL; in rt_mutex_slowunlock()
1318 * raw_spin_unlock(&lock->wait_lock); in rt_mutex_slowunlock()
1320 while (!rt_mutex_has_waiters(lock)) { in rt_mutex_slowunlock()
1321 /* Drops lock->wait_lock ! */ in rt_mutex_slowunlock()
1322 if (unlock_rt_mutex_safe(lock, flags) == true) in rt_mutex_slowunlock()
1325 raw_spin_lock_irqsave(&lock->wait_lock, flags); in rt_mutex_slowunlock()
1334 mark_wakeup_next_waiter(&wqh, lock); in rt_mutex_slowunlock()
1335 raw_spin_unlock_irqrestore(&lock->wait_lock, flags); in rt_mutex_slowunlock()
1340 static __always_inline void __rt_mutex_unlock(struct rt_mutex_base *lock) in __rt_mutex_unlock() argument
1342 if (likely(rt_mutex_cmpxchg_release(lock, current, NULL))) in __rt_mutex_unlock()
1345 rt_mutex_slowunlock(lock); in __rt_mutex_unlock()
1349 static bool rtmutex_spin_on_owner(struct rt_mutex_base *lock, in rtmutex_spin_on_owner() argument
1358 if (owner != rt_mutex_owner(lock)) in rtmutex_spin_on_owner()
1362 * the lock owner still matches @owner. If that fails, in rtmutex_spin_on_owner()
1369 * - the lock owner has been scheduled out in rtmutex_spin_on_owner()
1376 rt_mutex_waiter_is_top_waiter(lock, waiter) || in rtmutex_spin_on_owner()
1387 static bool rtmutex_spin_on_owner(struct rt_mutex_base *lock, in rtmutex_spin_on_owner() argument
1403 * Remove a waiter from a lock and give up
1405 * Must be called with lock->wait_lock held and interrupts disabled. It must
1408 static void __sched remove_waiter(struct rt_mutex_base *lock, in remove_waiter() argument
1411 bool is_top_waiter = (waiter == rt_mutex_top_waiter(lock)); in remove_waiter()
1412 struct task_struct *owner = rt_mutex_owner(lock); in remove_waiter()
1415 lockdep_assert_held(&lock->wait_lock); in remove_waiter()
1418 rt_mutex_dequeue(lock, waiter); in remove_waiter()
1424 * waiter of the lock and there is an owner to update. in remove_waiter()
1433 if (rt_mutex_has_waiters(lock)) in remove_waiter()
1434 rt_mutex_enqueue_pi(owner, rt_mutex_top_waiter(lock)); in remove_waiter()
1438 /* Store the lock on which owner is blocked or NULL */ in remove_waiter()
1453 raw_spin_unlock_irq(&lock->wait_lock); in remove_waiter()
1455 rt_mutex_adjust_prio_chain(owner, RT_MUTEX_MIN_CHAINWALK, lock, in remove_waiter()
1458 raw_spin_lock_irq(&lock->wait_lock); in remove_waiter()
1463 * @lock: the rt_mutex to take
1470 * Must be called with lock->wait_lock held and interrupts disabled
1472 static int __sched rt_mutex_slowlock_block(struct rt_mutex_base *lock, in rt_mutex_slowlock_block() argument
1478 struct rt_mutex *rtm = container_of(lock, struct rt_mutex, rtmutex); in rt_mutex_slowlock_block()
1483 /* Try to acquire the lock: */ in rt_mutex_slowlock_block()
1484 if (try_to_take_rt_mutex(lock, current, waiter)) in rt_mutex_slowlock_block()
1502 if (waiter == rt_mutex_top_waiter(lock)) in rt_mutex_slowlock_block()
1503 owner = rt_mutex_owner(lock); in rt_mutex_slowlock_block()
1506 raw_spin_unlock_irq(&lock->wait_lock); in rt_mutex_slowlock_block()
1508 if (!owner || !rtmutex_spin_on_owner(lock, waiter, owner)) in rt_mutex_slowlock_block()
1511 raw_spin_lock_irq(&lock->wait_lock); in rt_mutex_slowlock_block()
1543 * __rt_mutex_slowlock - Locking slowpath invoked with lock::wait_lock held
1544 * @lock: The rtmutex to block lock
1550 static int __sched __rt_mutex_slowlock(struct rt_mutex_base *lock, in __rt_mutex_slowlock() argument
1556 struct rt_mutex *rtm = container_of(lock, struct rt_mutex, rtmutex); in __rt_mutex_slowlock()
1560 lockdep_assert_held(&lock->wait_lock); in __rt_mutex_slowlock()
1562 /* Try to acquire the lock again: */ in __rt_mutex_slowlock()
1563 if (try_to_take_rt_mutex(lock, current, NULL)) { in __rt_mutex_slowlock()
1573 ret = task_blocks_on_rt_mutex(lock, waiter, current, ww_ctx, chwalk); in __rt_mutex_slowlock()
1575 ret = rt_mutex_slowlock_block(lock, ww_ctx, state, NULL, waiter); in __rt_mutex_slowlock()
1578 /* acquired the lock */ in __rt_mutex_slowlock()
1586 remove_waiter(lock, waiter); in __rt_mutex_slowlock()
1594 fixup_rt_mutex_waiters(lock); in __rt_mutex_slowlock()
1598 static inline int __rt_mutex_slowlock_locked(struct rt_mutex_base *lock, in __rt_mutex_slowlock_locked() argument
1608 ret = __rt_mutex_slowlock(lock, ww_ctx, state, RT_MUTEX_MIN_CHAINWALK, in __rt_mutex_slowlock_locked()
1617 * @lock: The rtmutex to block lock
1621 static int __sched rt_mutex_slowlock(struct rt_mutex_base *lock, in rt_mutex_slowlock() argument
1632 * rtmutex with lock->wait_lock held. But we cannot unconditionally in rt_mutex_slowlock()
1636 raw_spin_lock_irqsave(&lock->wait_lock, flags); in rt_mutex_slowlock()
1637 ret = __rt_mutex_slowlock_locked(lock, ww_ctx, state); in rt_mutex_slowlock()
1638 raw_spin_unlock_irqrestore(&lock->wait_lock, flags); in rt_mutex_slowlock()
1643 static __always_inline int __rt_mutex_lock(struct rt_mutex_base *lock, in __rt_mutex_lock() argument
1646 if (likely(rt_mutex_cmpxchg_acquire(lock, NULL, current))) in __rt_mutex_lock()
1649 return rt_mutex_slowlock(lock, NULL, state); in __rt_mutex_lock()
1659 * rtlock_slowlock_locked - Slow path lock acquisition for RT locks
1660 * @lock: The underlying RT mutex
1662 static void __sched rtlock_slowlock_locked(struct rt_mutex_base *lock) in rtlock_slowlock_locked() argument
1667 lockdep_assert_held(&lock->wait_lock); in rtlock_slowlock_locked()
1669 if (try_to_take_rt_mutex(lock, current, NULL)) in rtlock_slowlock_locked()
1677 task_blocks_on_rt_mutex(lock, &waiter, current, NULL, RT_MUTEX_MIN_CHAINWALK); in rtlock_slowlock_locked()
1680 /* Try to acquire the lock again */ in rtlock_slowlock_locked()
1681 if (try_to_take_rt_mutex(lock, current, &waiter)) in rtlock_slowlock_locked()
1684 if (&waiter == rt_mutex_top_waiter(lock)) in rtlock_slowlock_locked()
1685 owner = rt_mutex_owner(lock); in rtlock_slowlock_locked()
1688 raw_spin_unlock_irq(&lock->wait_lock); in rtlock_slowlock_locked()
1690 if (!owner || !rtmutex_spin_on_owner(lock, &waiter, owner)) in rtlock_slowlock_locked()
1693 raw_spin_lock_irq(&lock->wait_lock); in rtlock_slowlock_locked()
1704 fixup_rt_mutex_waiters(lock); in rtlock_slowlock_locked()
1708 static __always_inline void __sched rtlock_slowlock(struct rt_mutex_base *lock) in rtlock_slowlock() argument
1712 raw_spin_lock_irqsave(&lock->wait_lock, flags); in rtlock_slowlock()
1713 rtlock_slowlock_locked(lock); in rtlock_slowlock()
1714 raw_spin_unlock_irqrestore(&lock->wait_lock, flags); in rtlock_slowlock()