]> git.baikalelectronics.ru Git - kernel.git/commit
futex: Clarify futex_requeue() PI handling
authorThomas Gleixner <tglx@linutronix.de>
Sun, 15 Aug 2021 21:29:07 +0000 (23:29 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 17 Aug 2021 17:05:41 +0000 (19:05 +0200)
commitcfbc5b536b686809e921dc9f516ebc69ff1a9c9f
tree1256d8a6169d8f00044d360f7665fcc478e1bad5
parentdad60eb6f2f6af6243aaa4260f07e8b0bf231042
futex: Clarify futex_requeue() PI handling

When requeuing to a PI futex, then the requeue code tries to trylock the PI
futex on behalf of the topmost waiter on the inner 'waitqueue' futex. If
that succeeds, then PI state has to be allocated in order to requeue further
waiters to the PI futex.

The comment and the code are confusing, as the PI state allocation uses
lookup_pi_state(), which either attaches to an existing waiter or to the
owner. As the PI futex was just acquired, there cannot be a waiter on the
PI futex because the hash bucket lock is held.

Clarify the comment and use attach_to_pi_owner() directly. As the task on
which behalf the PI futex has been acquired is guaranteed to be alive and
not exiting, this call must succeed. Add a WARN_ON() in case that fails.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210815211305.305142462@linutronix.de
kernel/futex.c