From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760812AbZC3Vic (ORCPT ); Mon, 30 Mar 2009 17:38:32 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761480AbZC3ViD (ORCPT ); Mon, 30 Mar 2009 17:38:03 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:39810 "EHLO e7.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761711AbZC3ViB (ORCPT ); Mon, 30 Mar 2009 17:38:01 -0400 From: Darren Hart Subject: [tip PATCH v6 2/8] RFC: futex: futex_top_waiter() To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Sripathi Kodi , Peter Zijlstra , John Stultz , Steven Rostedt , Dinakar Guniguntala , Ulrich Drepper , Eric Dumazet , Ingo Molnar , Jakub Jelinek , Darren Hart , Thomas Gleixner , Sripathi Kodi , Peter Zijlstra , John Stultz , Steven Rostedt , Dinakar Guniguntala , Ulrich Drepper , Eric Dumazet , Ingo Molnar , Jakub Jelinek Date: Mon, 30 Mar 2009 14:37:47 -0700 Message-ID: <20090330213747.606.81857.stgit@Aeon> In-Reply-To: <20090330213306.606.9540.stgit@Aeon> References: <20090330213306.606.9540.stgit@Aeon> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Improve legibility by wrapping finding the top waiter in a function. This will be used by the follow-on patches for enabling requeue pi. Changelog: V6: -Shortened function length after review from tglx -Corrected kernel-doc formatting V4: -Simplified logic in the hb loop -Return the futex_q as the task can be had from there if needed -Updated comments and dropped the -safe iterator per review from tglx V3: -Comment linewidth cleanup V1: -Initial version Signed-off-by: Darren Hart Cc: Thomas Gleixner Cc: Sripathi Kodi Cc: Peter Zijlstra Cc: John Stultz Cc: Steven Rostedt Cc: Dinakar Guniguntala Cc: Ulrich Drepper Cc: Eric Dumazet Cc: Ingo Molnar Cc: Jakub Jelinek --- kernel/futex.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index b2ed762..8ebed88 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -276,6 +276,25 @@ void put_futex_key(int fshared, union futex_key *key) drop_futex_key_refs(key); } +/** + * futex_top_waiter() - return the highest priority waiter on a futex + * @hb: the hash bucket the futex_q's reside in + * @key: the futex key (to distinguish it from other futex futex_q's) + * + * Must be called with the hb lock held. + */ +static struct futex_q *futex_top_waiter(struct futex_hash_bucket *hb, + union futex_key *key) +{ + struct futex_q *this; + + plist_for_each_entry(this, &hb->chain, list) { + if (match_futex(&this->key, key)) + return this; + } + return NULL; +} + static u32 cmpxchg_futex_value_locked(u32 __user *uaddr, u32 uval, u32 newval) { u32 curval;