Skip to content

Commit

Permalink
futex: add helper to find the top prio waiter of a futex
Browse files Browse the repository at this point in the history
Improve legibility by wrapping finding the top waiter in a function.
This will be used by the follow-on patches for enabling requeue pi.

Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Darren Hart authored and Thomas Gleixner committed Apr 6, 2009
1 parent ca5f952 commit 4b1c486
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions kernel/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4b1c486

Please sign in to comment.