From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Carsten Emde <C.Emde@osadl.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
John Kacur <jkacur@redhat.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Darren Hart <darren@dvhart.com>,
Peter Zijlstra <peterz@infradead.org>,
Davidlohr Bueso <davidlohr@hp.com>, Kees Cook <kees@outflux.net>,
<wad@chromium.org>
Subject: [PATCH RT 15/25] futex: Split out the first waiter attachment from lookup_pi_state()
Date: Fri, 13 Mar 2015 11:18:40 -0400 [thread overview]
Message-ID: <20150313151836.766648114@goodmis.org> (raw)
In-Reply-To: 20150313151825.583263173@goodmis.org
[-- Attachment #1: 0015-futex-Split-out-the-first-waiter-attachment-from-loo.patch --]
[-- Type: text/plain, Size: 3032 bytes --]
3.2.68-rt99-rc1 stable review patch.
If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <tglx@linutronix.de>
upstream commit: 04e1b2e52b17195c9a1daa5935c55a4c8716095c
We want to be a bit more clever in futex_lock_pi_atomic() and separate
the possible states. Split out the code which attaches the first
waiter to the owner into a separate function. No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Darren Hart <darren@dvhart.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Davidlohr Bueso <davidlohr@hp.com>
Cc: Kees Cook <kees@outflux.net>
Cc: wad@chromium.org
Link: http://lkml.kernel.org/r/20140611204237.271300614@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/futex.c | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index 58c66defd69b..5015fbcb2d34 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -716,21 +716,16 @@ out_state:
return 0;
}
-static int
-lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
- union futex_key *key, struct futex_pi_state **ps)
+/*
+ * Lookup the task for the TID provided from user space and attach to
+ * it after doing proper sanity checks.
+ */
+static int attach_to_pi_owner(u32 uval, union futex_key *key,
+ struct futex_pi_state **ps)
{
- struct futex_q *match = futex_top_waiter(hb, key);
- struct futex_pi_state *pi_state = NULL;
- struct task_struct *p;
pid_t pid = uval & FUTEX_TID_MASK;
-
- /*
- * If there is a waiter on that futex, validate it and
- * attach to the pi_state when the validation succeeds.
- */
- if (match)
- return attach_to_pi_state(uval, match->pi_state, ps);
+ struct futex_pi_state *pi_state;
+ struct task_struct *p;
/*
* We are the first waiter - try to look up the real owner and attach
@@ -773,7 +768,7 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
pi_state = alloc_pi_state();
/*
- * Initialize the pi_mutex in locked state and make 'p'
+ * Initialize the pi_mutex in locked state and make @p
* the owner of it:
*/
rt_mutex_init_proxy_locked(&pi_state->pi_mutex, p);
@@ -793,6 +788,25 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
return 0;
}
+static int lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
+ union futex_key *key, struct futex_pi_state **ps)
+{
+ struct futex_q *match = futex_top_waiter(hb, key);
+
+ /*
+ * If there is a waiter on that futex, validate it and
+ * attach to the pi_state when the validation succeeds.
+ */
+ if (match)
+ return attach_to_pi_state(uval, match->pi_state, ps);
+
+ /*
+ * We are the first waiter - try to look up the owner based on
+ * @uval and attach to it.
+ */
+ return attach_to_pi_owner(uval, key, ps);
+}
+
/**
* futex_lock_pi_atomic() - Atomic work required to acquire a pi aware futex
* @uaddr: the pi futex user address
--
2.1.4
next prev parent reply other threads:[~2015-03-13 15:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 15:18 [PATCH RT 00/25] Linux 3.2.68-rt99-rc1 Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 01/25] gpio: omap: use raw locks for locking Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 02/25] create-rt-enqueue Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 03/25] rtmutex: Simplify rtmutex_slowtrylock() Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 04/25] rtmutex: Simplify and document try_to_take_rtmutex() Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 05/25] rtmutex: No need to keep task ref for lock owner check Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 06/25] rtmutex: Clarify the boost/deboost part Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 07/25] rtmutex: Document pi chain walk Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 08/25] rtmutex: Simplify remove_waiter() Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 09/25] rtmutex: Confine deadlock logic to futex Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 10/25] rtmutex: Cleanup deadlock detector debug logic Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 11/25] rtmutex: Avoid pointless requeueing in the deadlock detection chain walk Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 12/25] futex: Make unlock_pi more robust Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 13/25] futex: Use futex_top_waiter() in lookup_pi_state() Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 14/25] futex: Split out the waiter check from lookup_pi_state() Steven Rostedt
2015-03-13 15:18 ` Steven Rostedt [this message]
2015-03-13 15:18 ` [PATCH RT 16/25] futex: Simplify futex_lock_pi_atomic() and make it more robust Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 17/25] rt-mutex: avoid a NULL pointer dereference on deadlock Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 18/25] x86: UV: raw_spinlock conversion Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 20/25] arm/futex: disable preemption during futex_atomic_cmpxchg_inatomic() Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 21/25] scheduling while atomic in cgroup code Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 22/25] work-simple: Simple work queue implemenation Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 23/25] sunrpc: make svc_xprt_do_enqueue() use get_cpu_light() Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 24/25] lockdep: selftest: fix warnings due to missing PREEMPT_RT conditionals Steven Rostedt
2015-03-13 15:18 ` [PATCH RT 25/25] Linux 3.2.68-rt99-rc1 Steven Rostedt
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=20150313151836.766648114@goodmis.org \
--to=rostedt@goodmis.org \
--cc=C.Emde@osadl.org \
--cc=bigeasy@linutronix.de \
--cc=darren@dvhart.com \
--cc=davidlohr@hp.com \
--cc=jkacur@redhat.com \
--cc=kees@outflux.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=wad@chromium.org \
/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;
as well as URLs for NNTP newsgroup(s).