From: Darren Hart <dvhltc@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Darren Hart <dvhltc@us.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peterz@infradead.org>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: [PATCH 1/2] RFC: Fix futex_wake_op fault handling (NOT FOR INCLUSION)
Date: Thu, 08 Jan 2009 23:52:22 -0800 [thread overview]
Message-ID: <20090109075222.2226.43590.stgit@Aeon> (raw)
In-Reply-To: <20090109075148.2226.5222.stgit@Aeon>
As the the uaddr doesn't change after attempts to handle the fault, there is no
need to re-get the futex keys after get_user(). This patch makes successful
calls to futex_handle_fault() and get_user() start the retry from the same
point (right after the get_futex_key calls). Also simplify the logic and
corrects missing put on the futex keys. Finally, update the comment to more
accurate reflect the current code (we no hold the mm sem here).
Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
---
kernel/futex.c | 23 ++++++++---------------
1 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index 206d4c9..c15c029 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -745,7 +745,6 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
struct futex_q *this, *next;
int ret, op_ret, attempt = 0;
-retryfull:
ret = get_futex_key(uaddr1, fshared, &key1);
if (unlikely(ret != 0))
goto out;
@@ -782,25 +781,19 @@ retry:
}
/*
- * futex_atomic_op_inuser needs to both read and write
- * *(int __user *)uaddr2, but we can't modify it
- * non-atomically. Therefore, if get_user below is not
- * enough, we need to handle the fault ourselves, while
- * still holding the mmap_sem.
+ * We need to read and write *(int __user *)uaddr2 atomically.
+ * Therefore, if get_user below is not enough, we need to
+ * handle the fault ourselves.
*/
- if (attempt++) {
+ if (attempt++)
ret = futex_handle_fault((unsigned long)uaddr2,
attempt);
- if (ret)
- goto out_put_keys;
- goto retry;
- }
+ else
+ ret = get_user(dummy, uaddr2);
- ret = get_user(dummy, uaddr2);
if (ret)
- return ret;
-
- goto retryfull;
+ goto out_put_keys;
+ goto retry;
}
head = &hb1->chain;
next prev parent reply other threads:[~2009-01-09 7:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-09 7:52 [PATCH] RFC: futex fault handling and futex key references (NOT FOR INCLUSION) Darren Hart
2009-01-09 7:52 ` Darren Hart [this message]
2009-01-09 7:52 ` [PATCH 2/2] RFC: Fix futex_lock_pi fault handling " Darren Hart
2009-01-09 22:02 ` [PATCH] RFC: futex fault handling and futex key references " Peter Zijlstra
2009-01-10 5:54 ` Darren Hart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090109075222.2226.43590.stgit@Aeon \
--to=dvhltc@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox