Commit 81e6fd57 authored by Darren Hart's avatar Darren Hart Committed by Greg Kroah-Hartman

futex: Move drop_futex_key_refs out of spinlock'ed region

commit 89061d3d upstream.

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 -
which may be non-atomic.

It is therefore safer to defer this drop operation until after the
futex_hash_bucket spinlock has been dropped.

Originally-From: Helge Bahmann <hcb@chaoticmind.net>
Signed-off-by: default avatarDarren Hart <dvhltc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Dinakar Guniguntala <dino@in.ibm.com>
Cc: John Stultz <johnstul@linux.vnet.ibm.com>
Cc: Sven-Thorsten Dietrich <sdietrich@novell.com>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <4AD7A298.5040802@us.ibm.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6d57fbdd
...@@ -1028,7 +1028,6 @@ static inline ...@@ -1028,7 +1028,6 @@ static inline
void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key, void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key,
struct futex_hash_bucket *hb) struct futex_hash_bucket *hb)
{ {
drop_futex_key_refs(&q->key);
get_futex_key_refs(key); get_futex_key_refs(key);
q->key = *key; q->key = *key;
...@@ -1226,6 +1225,7 @@ retry_private: ...@@ -1226,6 +1225,7 @@ retry_private:
*/ */
if (ret == 1) { if (ret == 1) {
WARN_ON(pi_state); WARN_ON(pi_state);
drop_count++;
task_count++; task_count++;
ret = get_futex_value_locked(&curval2, uaddr2); ret = get_futex_value_locked(&curval2, uaddr2);
if (!ret) if (!ret)
...@@ -1304,6 +1304,7 @@ retry_private: ...@@ -1304,6 +1304,7 @@ retry_private:
if (ret == 1) { if (ret == 1) {
/* We got the lock. */ /* We got the lock. */
requeue_pi_wake_futex(this, &key2, hb2); requeue_pi_wake_futex(this, &key2, hb2);
drop_count++;
continue; continue;
} else if (ret) { } else if (ret) {
/* -EDEADLK */ /* -EDEADLK */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment