[PATCH] Move drop_futex_key_refs out of spinlock'ed region

From: Helge Bahmann
Date: Mon Oct 12 2009 - 05:31:35 EST


When requeuing tasks from one futex to another, the reference held
by the requeued task to the original futex location needs to
be dropped eventually. Dropping the reference may ultimately lead
to a call to "iput_final" and subsequently call into filesystem-
specific code. It is therefore safer to defer this drop operation
until after the futex_hash_bucket spinlock has been dropped.

Authored-by: Helge Bahmann <hcb@xxxxxxxxxxxxxxx>
Signed-off-by: Darren Hart <dvhltc@xxxxxxxxxx>
CC: stable@xxxxxxxxxx
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
CC: Eric Dumazet <eric.dumazet@xxxxxxxxx>
CC: Dinakar Guniguntala <dino@xxxxxxxxxx>
CC: John Stultz <johnstul@xxxxxxxxxx>
CC: Sven-Thorsten Dietrich <sdietrich@xxxxxxxxxx>
CC: John Kacur <jkacur@xxxxxxxxxx>


---
kernel/futex.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 4949d33..f49bf07 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1028,7 +1028,6 @@ static inline
void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key,
struct futex_hash_bucket *hb)
{
- drop_futex_key_refs(&q->key);
get_futex_key_refs(key);
q->key = *key;

@@ -1226,6 +1225,7 @@ retry_private:
*/
if (ret == 1) {
WARN_ON(pi_state);
+ drop_count++;
task_count++;
ret = get_futex_value_locked(&curval2, uaddr2);
if (!ret)
@@ -1304,6 +1304,7 @@ retry_private:
if (ret == 1) {
/* We got the lock. */
requeue_pi_wake_futex(this, &key2, hb2);
+ drop_count++;
continue;
} else if (ret) {
/* -EDEADLK */
--
1.5.6.5


--
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/