Lines Matching refs:lock

15 #include <trace/events/lock.h>
18 * queued_read_lock_slowpath - acquire read lock of a queued rwlock
19 * @lock: Pointer to queued rwlock structure
21 void __lockfunc queued_read_lock_slowpath(struct qrwlock *lock)
24 * Readers come here when they cannot get the lock without waiting
28 * Readers in interrupt context will get the lock immediately
29 * if the writer is just waiting (not holding the lock yet),
30 * so spin with ACQUIRE semantics until the lock is available
33 atomic_cond_read_acquire(&lock->cnts, !(VAL & _QW_LOCKED));
36 atomic_sub(_QR_BIAS, &lock->cnts);
38 trace_contention_begin(lock, LCB_F_SPIN | LCB_F_READ);
43 arch_spin_lock(&lock->wait_lock);
44 atomic_add(_QR_BIAS, &lock->cnts);
49 * section in the case that the lock is currently held for write.
51 atomic_cond_read_acquire(&lock->cnts, !(VAL & _QW_LOCKED));
56 arch_spin_unlock(&lock->wait_lock);
58 trace_contention_end(lock, 0);
63 * queued_write_lock_slowpath - acquire write lock of a queued rwlock
64 * @lock : Pointer to queued rwlock structure
66 void __lockfunc queued_write_lock_slowpath(struct qrwlock *lock)
70 trace_contention_begin(lock, LCB_F_SPIN | LCB_F_WRITE);
73 arch_spin_lock(&lock->wait_lock);
75 /* Try to acquire the lock directly if no reader is present */
76 if (!(cnts = atomic_read(&lock->cnts)) &&
77 atomic_try_cmpxchg_acquire(&lock->cnts, &cnts, _QW_LOCKED))
81 atomic_or(_QW_WAITING, &lock->cnts);
85 cnts = atomic_cond_read_relaxed(&lock->cnts, VAL == _QW_WAITING);
86 } while (!atomic_try_cmpxchg_acquire(&lock->cnts, &cnts, _QW_LOCKED));
88 arch_spin_unlock(&lock->wait_lock);
90 trace_contention_end(lock, 0);