Lines Matching defs:lock
19 * @lock: Pointer to queued spinlock structure
22 static __always_inline int queued_spin_is_locked(struct qspinlock *lock)
28 return atomic_read(&lock->val);
34 * @lock: queued spinlock structure
37 * N.B. Whenever there are tasks waiting for the lock, it is considered
38 * locked wrt the lockref code to avoid lock stealing by the lockref
39 * code and change things underneath the lock. This also allows some
42 static __always_inline int queued_spin_value_unlocked(struct qspinlock lock)
44 return !lock.val.counter;
48 * queued_spin_is_contended - check if the lock is contended
49 * @lock : Pointer to queued spinlock structure
50 * Return: 1 if lock contended, 0 otherwise
52 static __always_inline int queued_spin_is_contended(struct qspinlock *lock)
54 return atomic_read(&lock->val) & ~_Q_LOCKED_MASK;
58 * @lock : Pointer to queued spinlock structure
59 * Return: 1 if lock acquired, 0 if failed
61 static __always_inline int queued_spin_trylock(struct qspinlock *lock)
63 u32 val = atomic_read(&lock->val);
68 return likely(atomic_try_cmpxchg_acquire(&lock->val, &val, _Q_LOCKED_VAL));
71 extern void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
76 * @lock: Pointer to queued spinlock structure
78 static __always_inline void queued_spin_lock(struct qspinlock *lock)
82 if (likely(atomic_try_cmpxchg_acquire(&lock->val, &val, _Q_LOCKED_VAL)))
85 queued_spin_lock_slowpath(lock, val);
92 * @lock : Pointer to queued spinlock structure
94 static __always_inline void queued_spin_unlock(struct qspinlock *lock)
99 smp_store_release(&lock->locked, 0);
104 static __always_inline bool virt_spin_lock(struct qspinlock *lock)