Lines Matching refs:we

28 with the resource.  This is a priority inversion.  What we want to prevent
40 to release the lock, because for all we know, B is a CPU hog and will
61 for this document. Here we only discuss PI.
144 To show where two chains merge, we could add another process F and
154 Here we show both chains:
162 For PI to work, the processes at the right end of these chains (or we may
166 Also since a mutex may have more than one process blocked on it, we can
167 have multiple chains merge at mutexes. If we add another process G that is
238 the nesting of mutexes. Let's look at the example where we have 3 mutexes,
283 Now we add 4 processes that run each of these functions separately.
286 in func4 in the "do something again" area, we have a locking that follows:
295 And thus we have the chain A->L1->B->L2->C->L3->D.
302 Now since mutexes can be defined by user-land applications, we don't want a DOS
397 by the task, so we only need to compare the priority of that top pi waiter
407 with what we believe is the best. It walks the PI chain by only grabbing
447 we don't need to do any more changes to the priority of the current task, or any
452 the priority the task is set at. If they are equal, then we are done with
457 Next, we look at the mutex that the task is blocked on. The mutex's wait_lock
459 pi_lock and wait_lock goes in the opposite direction. If we fail to grab the
460 lock, the pi_lock is released, and we restart the loop.
462 Now that we have both the pi_lock of the task as well as the wait_lock of
463 the mutex the task is blocked on, we update the task's waiter's plist node
466 Now we release the pi_lock of the task.
468 Next the owner of the mutex has its pi_lock taken, so we can update the
470 process on the mutex's wait_list, then we remove the previous top waiter
478 If the task was not the top waiter of the mutex, but it was before we
479 did the priority updates, that means we are deboosting/lowering the
483 Lastly, we unlock both the pi_lock of the task, as well as the mutex's
489 since we just grab the mutex's wait_lock. And one could be right.
492 we have taken that task's pi_lock at the beginning of the loop.
494 process as the tasked being worked on, we are OK.
505 wait_lock. If we fail that lock, we release the pi_lock of the
509 the entire time, and it is not let go when we grab the pi_lock of the
528 Why is this important? Why can't we just give the mutex to another process
546 To solve this, we introduced Pending Ownership and Lock Stealing. When a
550 process does come along and wants that mutex, we let the higher priority
562 done when we have CMPXCHG enabled (otherwise the fast taking automatically
567 we go about the slow path (rt_mutex_slowlock).
586 the current task also won't have any waiters. But we don't have the lock
587 yet, so we assume we are going to be a waiter. The reason for this is to
594 Now that we know that we can't have any races with the owner releasing the
595 mutex, we check to see if we can take the ownership. This is done if the
596 mutex doesn't have a owner, or if we can steal the mutex from a pending
597 owner. Let's look at the situations we have here.
607 itself. If so, we succeed and leave the function, clearing the "Pending
610 If the pending owner is not current, we check to see if the current priority is
611 higher than the pending owner. If not, we fail the function and return.
616 to update the pending owner's pi_list, since we only worry about processes
619 If there are waiters on this mutex, and we just stole the ownership, we need
630 If there is no owner (or we successfully stole the lock), we set the owner
632 mutex actually has waiters, or we clear the flag if it doesn't. See, it was
633 OK that we set that flag early, since now it is cleared.
638 The most interesting case is when we fail to take ownership. This means that
644 If the mutex has a timeout, we set up a timer to go off to break us out
645 of this mutex if we failed to get it after a specified amount of time.
647 Now we enter a loop that will continue to try to take ownership of the mutex, or
650 Once again we try to take the mutex. This will usually fail the first time
661 field is NULL then we need to set up the accounting for it.
671 Since the wait_lock was taken at the entry of the slow lock, we can safely
673 priority process currently waiting on this mutex, then we remove the
676 has changed, we call rt_mutex_adjust_prio on the owner to see if the owner
680 (or deadlock checking is on), we unlock the wait_lock of the mutex and go ahead
684 mutex (waiter "task" field is not NULL), then we go to sleep (call schedule).
690 1) we were given pending ownership of the mutex.
691 2) we received a signal and was TASK_INTERRUPTIBLE
692 3) we had a timeout and was TASK_INTERRUPTIBLE
694 In any of these cases, we continue the loop and once again try to grab the
695 ownership of the mutex. If we succeed, we exit the loop, otherwise we continue
696 and on signal and timeout, will exit the loop, or if we had the mutex stolen
697 we just simply add ourselves back on the lists and go back to sleep.
720 "Has Waiters" flag of the mutex's owner, we use this to know if we need to
742 If there are waiters, then we need to wake one up and give that waiter
759 the mutex still has waiters pending, we add the new top waiter to the pi_list
762 Finally we unlock the pi_lock of the pending owner and wake it up.