Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139023
b: refs/heads/master
c: ac6e60e
h: refs/heads/master
i:
  139021: 23dd058
  139019: 314fc84
  139015: d0e16cc
  139007: 588d1b5
v: v3
  • Loading branch information
Chris Mason authored and Ingo Molnar committed Jan 14, 2009
1 parent 4f1e232 commit 4343640
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 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: 0d66bf6d3514b35eb6897629059443132992dbd7
refs/heads/master: ac6e60ee405aa3bf718f7fe4cb01b7ee0b8877ec
20 changes: 7 additions & 13 deletions trunk/kernel/mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,6 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
for (;;) {
struct thread_info *owner;

/*
* If there are pending waiters, join them.
*/
if (!list_empty(&lock->wait_list))
break;

/*
* If there's an owner, wait for it to either
* release the lock or go to sleep.
Expand All @@ -184,6 +178,13 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
if (owner && !mutex_spin_on_owner(lock, owner))
break;

if (atomic_cmpxchg(&lock->count, 1, 0) == 1) {
lock_acquired(&lock->dep_map, ip);
mutex_set_owner(lock);
preempt_enable();
return 0;
}

/*
* When there's no owner, we might have preempted between the
* owner acquiring the lock and setting the owner field. If
Expand All @@ -193,13 +194,6 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
if (!owner && (need_resched() || rt_task(task)))
break;

if (atomic_cmpxchg(&lock->count, 1, 0) == 1) {
lock_acquired(&lock->dep_map, ip);
mutex_set_owner(lock);
preempt_enable();
return 0;
}

/*
* The cpu_relax() call is a compiler barrier which forces
* everything in this loop to be re-loaded. We don't need
Expand Down

0 comments on commit 4343640

Please sign in to comment.