Skip to content

Commit 3f6b233

Browse files
Sebastian Andrzej SiewiorPeter Zijlstra
authored andcommitted
futex: Acquire a hash reference in futex_wait_multiple_setup()
futex_wait_multiple_setup() changes task_struct::__state to !TASK_RUNNING and then enqueues on multiple futexes. Every futex_q_lock() acquires a reference on the global hash which is dropped later. If a rehash is in progress then the loop will block on mm_struct::futex_hash_bucket for the rehash to complete and this will lose the previously set task_struct::__state. Acquire a reference on the local hash to avoiding blocking on mm_struct::futex_hash_bucket. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d854e4e commit 3f6b233

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/futex/waitwake.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@ int futex_wait_multiple_setup(struct futex_vector *vs, int count, int *woken)
406406
int ret, i;
407407
u32 uval;
408408

409+
/*
410+
* Make sure to have a reference on the private_hash such that we
411+
* don't block on rehash after changing the task state below.
412+
*/
413+
guard(private_hash)();
414+
409415
/*
410416
* Enqueuing multiple futexes is tricky, because we need to enqueue
411417
* each futex on the list before dealing with the next one to avoid

0 commit comments

Comments
 (0)