Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 31815
b: refs/heads/master
c: 8b8f319
h: refs/heads/master
i:
  31813: 5d53cc0
  31811: ac748fc
  31807: 751c8fe
v: v3
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Jul 3, 2006
1 parent 32d0c35 commit e89b6d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f2eace23e924bd3f05aedea4fc505eb5508d2d93
refs/heads/master: 8b8f319fc7f4ab59f567d6a401a62659b3d37007
28 changes: 18 additions & 10 deletions trunk/kernel/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,22 @@ static int unlock_futex_pi(u32 __user *uaddr, u32 uval)
return 0;
}

/*
* Express the locking dependencies for lockdep:
*/
static inline void
double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
{
if (hb1 <= hb2) {
spin_lock(&hb1->lock);
if (hb1 < hb2)
spin_lock_nested(&hb2->lock, SINGLE_DEPTH_NESTING);
} else { /* hb1 > hb2 */
spin_lock(&hb2->lock);
spin_lock_nested(&hb1->lock, SINGLE_DEPTH_NESTING);
}
}

/*
* Wake up all waiters hashed on the physical page that is mapped
* to this virtual address:
Expand Down Expand Up @@ -674,11 +690,7 @@ futex_wake_op(u32 __user *uaddr1, u32 __user *uaddr2,
hb2 = hash_futex(&key2);

retry:
if (hb1 < hb2)
spin_lock(&hb1->lock);
spin_lock(&hb2->lock);
if (hb1 > hb2)
spin_lock(&hb1->lock);
double_lock_hb(hb1, hb2);

op_ret = futex_atomic_op_inuser(op, uaddr2);
if (unlikely(op_ret < 0)) {
Expand Down Expand Up @@ -787,11 +799,7 @@ static int futex_requeue(u32 __user *uaddr1, u32 __user *uaddr2,
hb1 = hash_futex(&key1);
hb2 = hash_futex(&key2);

if (hb1 < hb2)
spin_lock(&hb1->lock);
spin_lock(&hb2->lock);
if (hb1 > hb2)
spin_lock(&hb1->lock);
double_lock_hb(hb1, hb2);

if (likely(cmpval != NULL)) {
u32 curval;
Expand Down

0 comments on commit e89b6d5

Please sign in to comment.