Lines Matching +full:lock +full:- +full:state

1 // SPDX-License-Identifier: GPL-2.0-only
8 * - Contrary to plain rtmutexes, spinlocks and rwlocks are state
9 * preserving. The task state is saved before blocking on the underlying
10 * rtmutex, and restored when the lock has been acquired. Regular wakeups
11 * during that time are redirected to the saved state so no wake up is
14 * - Non RT spin/rwlocks disable preemption and eventually interrupts.
19 * rcu_read_lock() across the lock held section.
28 * __might_resched() skips the state check as rtlocks are state
40 lockdep_assert(!current->pi_blocked_on); in rtlock_lock()
46 static __always_inline void __rt_spin_lock(spinlock_t *lock) in __rt_spin_lock() argument
49 rtlock_lock(&lock->lock); in __rt_spin_lock()
54 void __sched rt_spin_lock(spinlock_t *lock) in rt_spin_lock() argument
56 spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); in rt_spin_lock()
57 __rt_spin_lock(lock); in rt_spin_lock()
62 void __sched rt_spin_lock_nested(spinlock_t *lock, int subclass) in rt_spin_lock_nested() argument
64 spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); in rt_spin_lock_nested()
65 __rt_spin_lock(lock); in rt_spin_lock_nested()
69 void __sched rt_spin_lock_nest_lock(spinlock_t *lock, in rt_spin_lock_nest_lock() argument
72 spin_acquire_nest(&lock->dep_map, 0, 0, nest_lock, _RET_IP_); in rt_spin_lock_nest_lock()
73 __rt_spin_lock(lock); in rt_spin_lock_nest_lock()
78 void __sched rt_spin_unlock(spinlock_t *lock) in rt_spin_unlock() argument
80 spin_release(&lock->dep_map, _RET_IP_); in rt_spin_unlock()
84 if (unlikely(!rt_mutex_cmpxchg_release(&lock->lock, current, NULL))) in rt_spin_unlock()
85 rt_mutex_slowunlock(&lock->lock); in rt_spin_unlock()
90 * Wait for the lock to get unlocked: instead of polling for an unlock
91 * (like raw spinlocks do), lock and unlock, to force the kernel to
94 void __sched rt_spin_lock_unlock(spinlock_t *lock) in rt_spin_lock_unlock() argument
96 spin_lock(lock); in rt_spin_lock_unlock()
97 spin_unlock(lock); in rt_spin_lock_unlock()
101 static __always_inline int __rt_spin_trylock(spinlock_t *lock) in __rt_spin_trylock() argument
105 if (unlikely(!rt_mutex_cmpxchg_acquire(&lock->lock, NULL, current))) in __rt_spin_trylock()
106 ret = rt_mutex_slowtrylock(&lock->lock); in __rt_spin_trylock()
109 spin_acquire(&lock->dep_map, 0, 1, _RET_IP_); in __rt_spin_trylock()
116 int __sched rt_spin_trylock(spinlock_t *lock) in rt_spin_trylock() argument
118 return __rt_spin_trylock(lock); in rt_spin_trylock()
122 int __sched rt_spin_trylock_bh(spinlock_t *lock) in rt_spin_trylock_bh() argument
127 ret = __rt_spin_trylock(lock); in rt_spin_trylock_bh()
135 void __rt_spin_lock_init(spinlock_t *lock, const char *name, in __rt_spin_lock_init() argument
140 debug_check_no_locks_freed((void *)lock, sizeof(*lock)); in __rt_spin_lock_init()
141 lockdep_init_map_type(&lock->dep_map, name, key, 0, LD_WAIT_CONFIG, in __rt_spin_lock_init()
148 * RT-specific reader/writer locks
150 #define rwbase_set_and_save_current_state(state) \ argument
157 rwbase_rtmutex_lock_state(struct rt_mutex_base *rtm, unsigned int state) in rwbase_rtmutex_lock_state() argument
165 rwbase_rtmutex_slowlock_locked(struct rt_mutex_base *rtm, unsigned int state) in rwbase_rtmutex_slowlock_locked() argument
187 #define rwbase_signal_pending_state(state, current) (0) argument
204 ret = rwbase_read_trylock(&rwlock->rwbase); in rt_read_trylock()
206 rwlock_acquire_read(&rwlock->dep_map, 0, 1, _RET_IP_); in rt_read_trylock()
218 ret = rwbase_write_trylock(&rwlock->rwbase); in rt_write_trylock()
220 rwlock_acquire(&rwlock->dep_map, 0, 1, _RET_IP_); in rt_write_trylock()
231 rwlock_acquire_read(&rwlock->dep_map, 0, 0, _RET_IP_); in rt_read_lock()
232 rwbase_read_lock(&rwlock->rwbase, TASK_RTLOCK_WAIT); in rt_read_lock()
241 rwlock_acquire(&rwlock->dep_map, 0, 0, _RET_IP_); in rt_write_lock()
242 rwbase_write_lock(&rwlock->rwbase, TASK_RTLOCK_WAIT); in rt_write_lock()
252 rwlock_acquire(&rwlock->dep_map, subclass, 0, _RET_IP_); in rt_write_lock_nested()
253 rwbase_write_lock(&rwlock->rwbase, TASK_RTLOCK_WAIT); in rt_write_lock_nested()
262 rwlock_release(&rwlock->dep_map, _RET_IP_); in rt_read_unlock()
265 rwbase_read_unlock(&rwlock->rwbase, TASK_RTLOCK_WAIT); in rt_read_unlock()
271 rwlock_release(&rwlock->dep_map, _RET_IP_); in rt_write_unlock()
274 rwbase_write_unlock(&rwlock->rwbase); in rt_write_unlock()
283 lockdep_init_map_wait(&rwlock->dep_map, name, key, 0, LD_WAIT_CONFIG); in __rt_rwlock_init()