Lines Matching +full:wait +full:- +full:on +full:- +full:read

1 /* SPDX-License-Identifier: GPL-2.0 */
9 * Shared/intent/exclusive locks: sleepable read/write locks, like rw semaphores
10 * but with an additional state: read/shared, intent, exclusive/write
12 * The purpose of the intent state is to allow for greater concurrency on tree
13 * structures without deadlocking. In general, a read can't be upgraded to a
23 * six_lock_read(&foo->lock);
24 * six_unlock_read(&foo->lock);
27 * six_lock_intent(&foo->lock);
28 * six_lock_write(&foo->lock);
29 * six_unlock_write(&foo->lock);
30 * six_unlock_intent(&foo->lock);
37 * six_lock_downgrade() convert from intent to read
38 * six_lock_tryupgrade() attempt to convert from read to intent, may fail
42 * six_lock_type(&foo->lock, SIX_LOCK_read);
43 * six_trylock_convert(&foo->lock, SIX_LOCK_read, SIX_LOCK_intent)
44 * six_lock_type(&foo->lock, SIX_LOCK_write);
45 * six_unlock_type(&foo->lock, SIX_LOCK_write);
46 * six_unlock_type(&foo->lock, SIX_LOCK_intent);
48 * Lock sequence numbers - unlock(), relock():
50 * Locks embed sequences numbers, which are incremented on write lock/unlock.
56 * six_lock_read(&foo->lock);
57 * u32 seq = six_lock_seq(&foo->lock);
58 * six_unlock_read(&foo->lock);
62 * if (six_relock_read(&foo->lock, seq)) { ... }
69 * read and intent states that can be used to provide reentrancy by an upper
71 * read or intent state, six_lock_increment() can be used to bump the "lock
76 * six_lock_read(&foo->lock);
77 * six_lock_increment(&foo->lock, SIX_LOCK_read);
78 * six_unlock_read(&foo->lock);
79 * six_unlock_read(&foo->lock);
80 * foo->lock is now fully unlocked.
82 * Since the intent state supercedes read, it's legal to increment the read
95 * a cache and may reused, and lock ordering is based on a property of the
96 * object that will change when the object is reused - i.e. logical key order.
104 * Wait list entry interface:
107 * wait list entry. By embedding six_lock_waiter into another object, and by
116 * six_lock_waiter() will add the wait object to the waitlist re-trying taking
117 * the lock, and before calling should_sleep_fn, and the wait object will not
121 * Also, six_lock_waiter contains a timestamp, and waiters on a waitlist will
122 * have timestamps in strictly ascending order - this is so the timestamp can
169 * six_lock_init - initialize a six lock
181 * six_lock_seq - obtain current lock sequence number
184 * @lock should be held for read or intent, and not write
193 return lock->seq; in six_lock_seq()
199 * six_trylock_type - attempt to take a six lock without blocking
203 * Return: true on success, false on failure.
211 struct six_lock_waiter *wait,
216 * six_lock_waiter - take a lock, with full waitlist interface
219 * @wait: pointer to wait object, which will be added to lock's waitlist
227 * Return: 0 on success, or the return code from @should_sleep_fn on failure.
230 struct six_lock_waiter *wait, in six_lock_waiter() argument
233 return six_lock_ip_waiter(lock, type, wait, should_sleep_fn, p, _THIS_IP_); in six_lock_waiter()
237 * six_lock_ip - take a six lock lock
245 * Return: 0 on success, or the return code from @should_sleep_fn on failure.
251 struct six_lock_waiter wait; in six_lock_ip() local
253 return six_lock_ip_waiter(lock, type, &wait, should_sleep_fn, p, ip); in six_lock_ip()
257 * six_lock_type - take a six lock lock
264 * Return: 0 on success, or the return code from @should_sleep_fn on failure.
269 struct six_lock_waiter wait; in six_lock_type() local
271 return six_lock_ip_waiter(lock, type, &wait, should_sleep_fn, p, _THIS_IP_); in six_lock_type()
278 * six_relock_type - attempt to re-take a lock that was held previously
284 * Return: true on success, false on failure.
295 * six_unlock_type - drop a six lock
303 * six_lock_read(&foo->lock); read count 1
304 * six_lock_increment(&foo->lock, SIX_LOCK_read); read count 2
305 * six_lock_unlock(&foo->lock, SIX_LOCK_read); read count 1
306 * six_lock_unlock(&foo->lock, SIX_LOCK_read); read count 0
325 struct six_lock_waiter *wait, \
329 return six_lock_ip_waiter(lock, SIX_LOCK_##type, wait, should_sleep_fn, p, ip);\
365 __SIX_LOCK(read)