From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757304AbbCMPaY (ORCPT ); Fri, 13 Mar 2015 11:30:24 -0400 Received: from smtprelay0154.hostedemail.com ([216.40.44.154]:43415 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755922AbbCMPPU (ORCPT ); Fri, 13 Mar 2015 11:15:20 -0400 X-Session-Marker: 6E657665747340676F6F646D69732E6F7267 X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,,::::::::::::::::::::::::,RULES_HIT:355:379:871:988:989:1183:1260:1277:1312:1313:1314:1345:1516:1518:1519:1522:1534:1593:1594:1595:1596:1692:1730:1747:1777:1792:2392:2393:2560:2563:2828:3138:3139:3140:3141:3142:3876:3877:5007:6114:6261:6642:6748:7281:7901:10004:10848:11604:11914:12517:12519:13255:13895:14394:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: lock10_687d02421c534 X-Filterd-Recvd-Size: 4466 Message-Id: <20150313151517.332990976@goodmis.org> User-Agent: quilt/0.61-1 Date: Fri, 13 Mar 2015 11:15:09 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-rt-users Cc: Thomas Gleixner , Carsten Emde , Sebastian Andrzej Siewior , John Kacur , Paul Gortmaker , Darren Hart , Peter Zijlstra , Davidlohr Bueso , Kees Cook , Subject: [PATCH RT 15/31] futex: Split out the first waiter attachment from lookup_pi_state() References: <20150313151454.809081378@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0015-futex-Split-out-the-first-waiter-attachment-from-loo.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.10.70-rt75-rc1 stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner 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 Reviewed-by: Darren Hart Cc: Peter Zijlstra Cc: Davidlohr Bueso Cc: Kees Cook Cc: wad@chromium.org Link: http://lkml.kernel.org/r/20140611204237.271300614@linutronix.de Signed-off-by: Thomas Gleixner Signed-off-by: Steven Rostedt --- kernel/futex.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 8faa72097ebc..0b83f9ff2615 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