Lines Matching refs:owner

34  * The least significant 3 bits of the owner value has the following
49 * into the owner field. It is cleared after an unlock.
52 * pointer into the owner field with the RWSEM_READER_OWNED bit set.
53 * On unlock, the owner field will largely be left untouched. So
54 * for a free or reader-owned rwsem, the owner value may contain
107 WARN_ONCE(c, "DEBUG_RWSEMS_WARN_ON(%s): count = 0x%lx, magic = 0x%lx, owner = 0x%lx, curr 0x%lx, list %sempty\n",\
110 atomic_long_read(&(sem)->owner), (long)current, \
168 * All writes to owner are protected by WRITE_ONCE() to make sure that
170 * the owner value concurrently without lock. Read from owner, however,
176 atomic_long_set(&sem->owner, (long)current);
181 atomic_long_set(&sem->owner, 0);
185 * Test the flags in the owner field.
189 return atomic_long_read(&sem->owner) & flags;
194 * the owner field.
196 * Note that the owner value just indicates the task has owned the rwsem
197 * previously, it may not be the real owner or one of the real owners
203 struct task_struct *owner)
205 unsigned long val = (unsigned long)owner | RWSEM_READER_OWNED |
206 (atomic_long_read(&sem->owner) & RWSEM_RD_NONSPINNABLE);
208 atomic_long_set(&sem->owner, val);
236 * is a task pointer in owner of a reader-owned rwsem, it will be the
237 * real owner or one of the real owners. The only exception is when the
242 unsigned long val = atomic_long_read(&sem->owner);
245 if (atomic_long_try_cmpxchg(&sem->owner, &val,
262 unsigned long owner = atomic_long_read(&sem->owner);
265 if (!(owner & RWSEM_READER_OWNED))
267 if (owner & RWSEM_NONSPINNABLE)
269 } while (!atomic_long_try_cmpxchg(&sem->owner, &owner,
270 owner | RWSEM_NONSPINNABLE));
282 * Return just the real task structure pointer of the owner
287 (atomic_long_read(&sem->owner) & ~RWSEM_OWNER_FLAGS_MASK);
291 * Return the real task structure pointer of the owner and the embedded
292 * flags in the owner. pflags must be non-NULL.
297 unsigned long owner = atomic_long_read(&sem->owner);
299 *pflags = owner & RWSEM_OWNER_FLAGS_MASK;
300 return (struct task_struct *)(owner & ~RWSEM_OWNER_FLAGS_MASK);
312 * (3) the owner field has RWSEM_READ_OWNED bit set.
339 atomic_long_set(&sem->owner, 0L);
444 struct task_struct *owner;
469 owner = waiter->task;
471 owner = (void *)((unsigned long)owner | RWSEM_RD_NONSPINNABLE);
474 __rwsem_set_reader_owned(sem, owner);
646 static inline bool owner_on_cpu(struct task_struct *owner)
652 return owner->on_cpu && !vcpu_is_preempted(task_cpu(owner));
658 struct task_struct *owner;
669 owner = rwsem_owner_flags(sem, &flags);
671 * Don't check the read-owner as the entry may be stale.
674 (owner && !(flags & RWSEM_READER_OWNED) && !owner_on_cpu(owner)))
685 * depending on the lock owner state.
686 * OWNER_NULL : owner is currently NULL
687 * OWNER_WRITER: when owner changes and is a writer
688 * OWNER_READER: when owner changes and the new owner may be a reader.
691 * owner stops running, is unknown, or its timeslice has
703 rwsem_owner_state(struct task_struct *owner, unsigned long flags, unsigned long nonspinnable)
711 return owner ? OWNER_WRITER : OWNER_NULL;
717 struct task_struct *new, *owner;
721 owner = rwsem_owner_flags(sem, &flags);
722 state = rwsem_owner_state(owner, flags, nonspinnable);
730 * on the owner as well. Once that writer acquires the lock,
735 if ((new != owner) || (new_flags != flags)) {
741 * Ensure we emit the owner->on_cpu, dereference _after_
742 * checking sem->owner still matches owner, if that fails,
743 * owner might point to free()d memory, if it still matches,
748 if (need_resched() || !owner_on_cpu(owner)) {
801 * Optimistically spin on the owner field and attempt to acquire the
802 * lock whenever the owner changes. Spinning will be stopped when:
828 * the owner state changes from non-reader to reader.
859 * spinning while a NULL owner is detected may miss some
866 * 1) The lock owner is in the process of releasing the
867 * lock, sem->owner is cleared but the lock has not
869 * 2) The lock was free and owner cleared, but another
871 * we try to get it. The new owner may be a spinnable
878 * new owner is not a writer or spinnable, the RT task will
881 * If the owner is a writer, the need_resched() check is
882 * done inside rwsem_spin_on_owner(). If the owner is not
910 * Clear the owner's RWSEM_WR_NONSPINNABLE bit if it is set. This should
916 * just stolen the rwsem and set the owner, but just clearing the
922 atomic_long_andnot(RWSEM_WR_NONSPINNABLE, &sem->owner);
933 * 2) The lock is previously not reader-owned or the last read owner changes.
947 unsigned long owner = atomic_long_read(&sem->owner);
949 if (!(owner & RWSEM_READER_OWNED))
952 if (((owner ^ last_rowner) & ~RWSEM_OWNER_FLAGS_MASK) &&
1000 * Save the current read-owner of rwsem, if available, and the
1003 waiter.last_rowner = atomic_long_read(&sem->owner);
1120 * This function is called by the a write lock owner. So the owner value
1127 atomic_long_or(RWSEM_RD_NONSPINNABLE, &sem->owner);
1157 disable_rspin = atomic_long_read(&sem->owner) & RWSEM_NONSPINNABLE;
1220 * the lock, attempt to spin on owner to accelerate lock
1221 * transfer. If the previous owner is a on-cpu writer and it
1464 * sem->owner may differ from current if the ownership is transferred