Skip to content

Commit 249955e

Browse files
committed
futex: Clarify comment for requeue_pi_wake_futex()
It's slightly confusing. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20210902094414.618613025@linutronix.de
1 parent 4f07ec0 commit 249955e

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

kernel/futex.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,12 +1954,26 @@ static inline int futex_requeue_pi_wakeup_sync(struct futex_q *q)
19541954
* @hb: the hash_bucket of the requeue target futex
19551955
*
19561956
* During futex_requeue, with requeue_pi=1, it is possible to acquire the
1957-
* target futex if it is uncontended or via a lock steal. Set the futex_q key
1958-
* to the requeue target futex so the waiter can detect the wakeup on the right
1959-
* futex, but remove it from the hb and NULL the rt_waiter so it can detect
1960-
* atomic lock acquisition. Set the q->lock_ptr to the requeue target hb->lock
1961-
* to protect access to the pi_state to fixup the owner later. Must be called
1962-
* with both q->lock_ptr and hb->lock held.
1957+
* target futex if it is uncontended or via a lock steal.
1958+
*
1959+
* 1) Set @q::key to the requeue target futex key so the waiter can detect
1960+
* the wakeup on the right futex.
1961+
*
1962+
* 2) Dequeue @q from the hash bucket.
1963+
*
1964+
* 3) Set @q::rt_waiter to NULL so the woken up task can detect atomic lock
1965+
* acquisition.
1966+
*
1967+
* 4) Set the q->lock_ptr to the requeue target hb->lock for the case that
1968+
* the waiter has to fixup the pi state.
1969+
*
1970+
* 5) Complete the requeue state so the waiter can make progress. After
1971+
* this point the waiter task can return from the syscall immediately in
1972+
* case that the pi state does not have to be fixed up.
1973+
*
1974+
* 6) Wake the waiter task.
1975+
*
1976+
* Must be called with both q->lock_ptr and hb->lock held.
19631977
*/
19641978
static inline
19651979
void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key,

0 commit comments

Comments
 (0)