From 434364010ceaf597eba831b74f23ca5f325573d5 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Wed, 14 Jan 2009 17:29:31 +0100 Subject: [PATCH] --- yaml --- r: 139023 b: refs/heads/master c: ac6e60ee405aa3bf718f7fe4cb01b7ee0b8877ec h: refs/heads/master i: 139021: 23dd058b0d182feec8cb084b6125f5512a775037 139019: 314fc841c349cb1c707a48c6cdac375fab70a912 139015: d0e16ccea469e5bceb4e19ab9661be160a7a0998 139007: 588d1b5e3b7f7665278e8b0808a5485b440d2878 v: v3 --- [refs] | 2 +- trunk/kernel/mutex.c | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/[refs] b/[refs] index e668606c78af..904fce93dc48 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0d66bf6d3514b35eb6897629059443132992dbd7 +refs/heads/master: ac6e60ee405aa3bf718f7fe4cb01b7ee0b8877ec diff --git a/trunk/kernel/mutex.c b/trunk/kernel/mutex.c index ff42e975590c..5d79781394a3 100644 --- a/trunk/kernel/mutex.c +++ b/trunk/kernel/mutex.c @@ -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. @@ -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 @@ -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