Lines Matching refs:task

355 static __always_inline int __waiter_prio(struct task_struct *task)
357 int prio = task->prio;
369 waiter_update_prio(struct rt_mutex_waiter *waiter, struct task_struct *task)
374 waiter->tree.prio = __waiter_prio(task);
375 waiter->tree.deadline = task->dl.deadline;
382 waiter_clone_prio(struct rt_mutex_waiter *waiter, struct task_struct *task)
385 lockdep_assert_held(&task->pi_lock);
516 rt_mutex_enqueue_pi(struct task_struct *task, struct rt_mutex_waiter *waiter)
518 lockdep_assert_held(&task->pi_lock);
520 rb_add_cached(&waiter->pi_tree.entry, &task->pi_waiters, __pi_waiter_less);
524 rt_mutex_dequeue_pi(struct task_struct *task, struct rt_mutex_waiter *waiter)
526 lockdep_assert_held(&task->pi_lock);
531 rb_erase_cached(&waiter->pi_tree.entry, &task->pi_waiters);
545 pi_task = task_top_pi_waiter(p)->task;
552 struct task_struct *task,
558 get_task_struct(task);
559 wqh->rtlock_task = task;
561 wake_q_add(&wqh->head, task);
568 rt_mutex_wake_q_add_task(wqh, w->task, w->wake_state);
615 * Decreases task's usage by one - may thus free the task.
617 * @task: the task owning the mutex (owner) for which a chain walk is
621 * things for a task that has just got its priority adjusted, and
626 * @orig_waiter: rt_mutex_waiter struct for the task that has just donated
636 * [R] refcount on task
637 * [Pn] task->pi_lock held
643 * task->pi_lock
647 * @task [R]
659 * [1] lock(task->pi_lock); [R] acquire [P1]
660 * [2] waiter = task->pi_blocked_on; [P1]
664 * unlock(task->pi_lock); release [P1]
669 * [8] unlock(task->pi_lock); release [P1]
670 * put_task_struct(task); release [R]
672 * [10] task = owner(lock); [L]
673 * get_task_struct(task); [L] acquire [R]
674 * lock(task->pi_lock); [L] acquire [P2]
677 * [13] unlock(task->pi_lock); release [P2]
681 * Where P1 is the blocking task and P2 is the lock owner; going up one step
682 * the owner becomes the next blocked task etc..
686 static int __sched rt_mutex_adjust_prio_chain(struct task_struct *task,
722 "task: %s (%d)\n", max_lock_depth,
725 put_task_struct(task);
732 * @task. So everything can have changed under us since the
740 raw_spin_lock_irq(&task->pi_lock);
743 * [2] Get the waiter on which @task is blocked on.
745 waiter = task->pi_blocked_on;
748 * [3] check_exit_conditions_1() protected by task->pi_lock.
767 * We dropped all locks after taking a refcount on @task, so
768 * the task might have moved on in the lock chain or even left
772 * We stored the lock on which @task was blocked in @next_lock,
804 * Drop out, when the task has no waiters. Note,
809 if (!task_has_pi_waiters(task))
813 * are not the top pi waiter of the task. If deadlock
817 if (top_waiter != task_top_pi_waiter(task)) {
826 * If the waiter priority is the same as the task priority
832 if (rt_waiter_node_equal(&waiter->tree, task_to_waiter_node(task))) {
840 * [4] Get the next lock; per holding task->pi_lock we can't unblock
845 * [5] We need to trylock here as we are holding task->pi_lock,
849 * Per the above, holding task->pi_lock guarantees lock exists, so
854 raw_spin_unlock_irq(&task->pi_lock);
860 * [6] check_exit_conditions_2() protected by task->pi_lock and
865 * current lock is owned by the task which initiated the chain
895 * No requeue[7] here. Just release @task [8]
897 raw_spin_unlock(&task->pi_lock);
898 put_task_struct(task);
909 /* [10] Grab the next task, i.e. owner of @lock */
910 task = get_task_struct(rt_mutex_owner(lock));
911 raw_spin_lock(&task->pi_lock);
919 next_lock = task_blocked_on_lock(task);
926 raw_spin_unlock(&task->pi_lock);
956 waiter_update_prio(waiter, task);
961 * [8] Release the (blocking) task in preparation for
962 * taking the owner task in [10].
964 * Since we hold lock->waiter_lock, task cannot unblock, even if we
965 * release task->pi_lock.
967 raw_spin_unlock(&task->pi_lock);
968 put_task_struct(task);
985 wake_up_state(top_waiter->task, top_waiter->wake_state);
991 * [10] Grab the next task, i.e. the owner of @lock
996 task = get_task_struct(rt_mutex_owner(lock));
997 raw_spin_lock(&task->pi_lock);
1007 rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
1008 waiter_clone_prio(waiter, task);
1009 rt_mutex_enqueue_pi(task, waiter);
1010 rt_mutex_adjust_prio(lock, task);
1023 rt_mutex_dequeue_pi(task, waiter);
1025 waiter_clone_prio(waiter, task);
1026 rt_mutex_enqueue_pi(task, waiter);
1027 rt_mutex_adjust_prio(lock, task);
1036 * [12] check_exit_conditions_4() protected by task->pi_lock
1040 * Check whether the task which owns the current lock is pi
1043 * task->pi_lock next_lock cannot be dereferenced anymore.
1045 next_lock = task_blocked_on_lock(task);
1053 raw_spin_unlock(&task->pi_lock);
1077 raw_spin_unlock_irq(&task->pi_lock);
1079 put_task_struct(task);
1090 * @task: The task which wants to acquire the lock
1095 try_to_take_rt_mutex(struct rt_mutex_base *lock, struct task_struct *task,
1114 * - @task acquires the lock and there are no other
1115 * waiters. This is undone in rt_mutex_set_owner(@task) at
1127 * If @waiter != NULL, @task has already enqueued the waiter
1149 * If the lock has waiters already we check whether @task is
1152 * If there are no other waiters, @task can acquire
1153 * the lock. @task->pi_blocked_on is NULL, so it does
1158 if (!rt_mutex_steal(task_to_waiter(task),
1170 * pi_lock dance.@task->pi_blocked_on is NULL
1171 * and we have no waiters to enqueue in @task
1179 * Clear @task->pi_blocked_on. Requires protection by
1180 * @task->pi_lock. Redundant operation for the @waiter == NULL
1184 raw_spin_lock(&task->pi_lock);
1185 task->pi_blocked_on = NULL;
1187 * Finish the lock acquisition. @task is the new owner. If
1189 * waiter into @task->pi_waiters tree.
1192 rt_mutex_enqueue_pi(task, rt_mutex_top_waiter(lock));
1193 raw_spin_unlock(&task->pi_lock);
1200 rt_mutex_set_owner(lock, task);
1214 struct task_struct *task,
1228 * Early deadlock detection. We really don't want the task to
1239 if (owner == task && !(build_ww_mutex() && ww_ctx))
1242 raw_spin_lock(&task->pi_lock);
1243 waiter->task = task;
1245 waiter_update_prio(waiter, task);
1246 waiter_clone_prio(waiter, task);
1253 task->pi_blocked_on = waiter;
1255 raw_spin_unlock(&task->pi_lock);
1265 raw_spin_lock(&task->pi_lock);
1267 task->pi_blocked_on = NULL;
1268 raw_spin_unlock(&task->pi_lock);
1310 next_lock, waiter, task);
1340 * task unblocks.
1350 * slow path making sure no task of lower priority than
1356 * We deboosted before waking the top waiter task such that we don't
1358 * p->pi_top_task pointer points to a blocked task). This however can
1360 * deboost but before waking our donor task, hence the preempt_disable()
1553 * When invoked from rt_mutex_start_proxy_lock() waiter::task != current !
1561 struct task_struct *waiter_task = waiter->task;
1596 * Don't walk the chain, if the owner task is not blocked
1617 * @state: the state the task should block in (TASK_INTERRUPTIBLE
1647 if (timeout && !timeout->task) {
1710 * @state: The task state for sleeping
1799 * @state: The task state for sleeping
1814 * same task and things get really confusing real fast.
1902 /* Restore the task state */