[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <174670043556.406.13694680291429891836.tip-bot2@tip-bot2>
Date: Thu, 08 May 2025 10:33:55 -0000
From: "tip-bot2 for Sebastian Andrzej Siewior" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: locking/futex] futex: Acquire a hash reference in
futex_wait_multiple_setup()
The following commit has been merged into the locking/futex branch of tip:
Commit-ID: 3f6b233018af2a6fb449faa324d94a437e2e47ce
Gitweb: https://git.kernel.org/tip/3f6b233018af2a6fb449faa324d94a437e2e47ce
Author: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
AuthorDate: Wed, 16 Apr 2025 18:29:08 +02:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Sat, 03 May 2025 12:02:06 +02:00
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 <bigeasy@...utronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Link: https://lore.kernel.org/r/20250416162921.513656-9-bigeasy@linutronix.de
---
kernel/futex/waitwake.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/futex/waitwake.c b/kernel/futex/waitwake.c
index d52541b..bd8fef0 100644
--- a/kernel/futex/waitwake.c
+++ b/kernel/futex/waitwake.c
@@ -407,6 +407,12 @@ int futex_wait_multiple_setup(struct futex_vector *vs, int count, int *woken)
u32 uval;
/*
+ * Make sure to have a reference on the private_hash such that we
+ * don't block on rehash after changing the task state below.
+ */
+ guard(private_hash)();
+
+ /*
* Enqueuing multiple futexes is tricky, because we need to enqueue
* each futex on the list before dealing with the next one to avoid
* deadlocking on the hash bucket. But, before enqueuing, we need to
Powered by blists - more mailing lists