rtmutes: Convert rtmutex.lock to raw_spinlock

Convert locks which cannot be sleeping locks in preempt-rt to
raw_spinlocks.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Thomas Gleixner 2009-11-17 18:22:11 +01:00
parent 1d61548254
commit d209d74d52
3 changed files with 30 additions and 30 deletions

View file

@ -24,7 +24,7 @@
* @owner: the mutex owner * @owner: the mutex owner
*/ */
struct rt_mutex { struct rt_mutex {
spinlock_t wait_lock; raw_spinlock_t wait_lock;
struct plist_head wait_list; struct plist_head wait_list;
struct task_struct *owner; struct task_struct *owner;
#ifdef CONFIG_DEBUG_RT_MUTEXES #ifdef CONFIG_DEBUG_RT_MUTEXES
@ -63,8 +63,8 @@ struct hrtimer_sleeper;
#endif #endif
#define __RT_MUTEX_INITIALIZER(mutexname) \ #define __RT_MUTEX_INITIALIZER(mutexname) \
{ .wait_lock = __SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \ { .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \
, .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \ , .wait_list = PLIST_HEAD_INIT_RAW(mutexname.wait_list, mutexname.wait_lock) \
, .owner = NULL \ , .owner = NULL \
__DEBUG_RT_MUTEX_INITIALIZER(mutexname)} __DEBUG_RT_MUTEX_INITIALIZER(mutexname)}

View file

@ -760,7 +760,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
if (!pi_state) if (!pi_state)
return -EINVAL; return -EINVAL;
spin_lock(&pi_state->pi_mutex.wait_lock); raw_spin_lock(&pi_state->pi_mutex.wait_lock);
new_owner = rt_mutex_next_owner(&pi_state->pi_mutex); new_owner = rt_mutex_next_owner(&pi_state->pi_mutex);
/* /*
@ -789,7 +789,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
else if (curval != uval) else if (curval != uval)
ret = -EINVAL; ret = -EINVAL;
if (ret) { if (ret) {
spin_unlock(&pi_state->pi_mutex.wait_lock); raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
return ret; return ret;
} }
} }
@ -805,7 +805,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
pi_state->owner = new_owner; pi_state->owner = new_owner;
raw_spin_unlock_irq(&new_owner->pi_lock); raw_spin_unlock_irq(&new_owner->pi_lock);
spin_unlock(&pi_state->pi_mutex.wait_lock); raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
rt_mutex_unlock(&pi_state->pi_mutex); rt_mutex_unlock(&pi_state->pi_mutex);
return 0; return 0;

View file

@ -231,7 +231,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
goto out_unlock_pi; goto out_unlock_pi;
lock = waiter->lock; lock = waiter->lock;
if (!spin_trylock(&lock->wait_lock)) { if (!raw_spin_trylock(&lock->wait_lock)) {
raw_spin_unlock_irqrestore(&task->pi_lock, flags); raw_spin_unlock_irqrestore(&task->pi_lock, flags);
cpu_relax(); cpu_relax();
goto retry; goto retry;
@ -240,7 +240,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
/* Deadlock detection */ /* Deadlock detection */
if (lock == orig_lock || rt_mutex_owner(lock) == top_task) { if (lock == orig_lock || rt_mutex_owner(lock) == top_task) {
debug_rt_mutex_deadlock(deadlock_detect, orig_waiter, lock); debug_rt_mutex_deadlock(deadlock_detect, orig_waiter, lock);
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
ret = deadlock_detect ? -EDEADLK : 0; ret = deadlock_detect ? -EDEADLK : 0;
goto out_unlock_pi; goto out_unlock_pi;
} }
@ -280,7 +280,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
raw_spin_unlock_irqrestore(&task->pi_lock, flags); raw_spin_unlock_irqrestore(&task->pi_lock, flags);
top_waiter = rt_mutex_top_waiter(lock); top_waiter = rt_mutex_top_waiter(lock);
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
if (!detect_deadlock && waiter != top_waiter) if (!detect_deadlock && waiter != top_waiter)
goto out_put_task; goto out_put_task;
@ -459,12 +459,12 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
*/ */
get_task_struct(owner); get_task_struct(owner);
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
res = rt_mutex_adjust_prio_chain(owner, detect_deadlock, lock, waiter, res = rt_mutex_adjust_prio_chain(owner, detect_deadlock, lock, waiter,
task); task);
spin_lock(&lock->wait_lock); raw_spin_lock(&lock->wait_lock);
return res; return res;
} }
@ -575,11 +575,11 @@ static void remove_waiter(struct rt_mutex *lock,
/* gets dropped in rt_mutex_adjust_prio_chain()! */ /* gets dropped in rt_mutex_adjust_prio_chain()! */
get_task_struct(owner); get_task_struct(owner);
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
rt_mutex_adjust_prio_chain(owner, 0, lock, NULL, current); rt_mutex_adjust_prio_chain(owner, 0, lock, NULL, current);
spin_lock(&lock->wait_lock); raw_spin_lock(&lock->wait_lock);
} }
/* /*
@ -672,14 +672,14 @@ __rt_mutex_slowlock(struct rt_mutex *lock, int state,
break; break;
} }
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
debug_rt_mutex_print_deadlock(waiter); debug_rt_mutex_print_deadlock(waiter);
if (waiter->task) if (waiter->task)
schedule_rt_mutex(lock); schedule_rt_mutex(lock);
spin_lock(&lock->wait_lock); raw_spin_lock(&lock->wait_lock);
set_current_state(state); set_current_state(state);
} }
@ -700,11 +700,11 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
debug_rt_mutex_init_waiter(&waiter); debug_rt_mutex_init_waiter(&waiter);
waiter.task = NULL; waiter.task = NULL;
spin_lock(&lock->wait_lock); raw_spin_lock(&lock->wait_lock);
/* Try to acquire the lock again: */ /* Try to acquire the lock again: */
if (try_to_take_rt_mutex(lock)) { if (try_to_take_rt_mutex(lock)) {
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
return 0; return 0;
} }
@ -731,7 +731,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
*/ */
fixup_rt_mutex_waiters(lock); fixup_rt_mutex_waiters(lock);
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
/* Remove pending timer: */ /* Remove pending timer: */
if (unlikely(timeout)) if (unlikely(timeout))
@ -758,7 +758,7 @@ rt_mutex_slowtrylock(struct rt_mutex *lock)
{ {
int ret = 0; int ret = 0;
spin_lock(&lock->wait_lock); raw_spin_lock(&lock->wait_lock);
if (likely(rt_mutex_owner(lock) != current)) { if (likely(rt_mutex_owner(lock) != current)) {
@ -770,7 +770,7 @@ rt_mutex_slowtrylock(struct rt_mutex *lock)
fixup_rt_mutex_waiters(lock); fixup_rt_mutex_waiters(lock);
} }
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
return ret; return ret;
} }
@ -781,7 +781,7 @@ rt_mutex_slowtrylock(struct rt_mutex *lock)
static void __sched static void __sched
rt_mutex_slowunlock(struct rt_mutex *lock) rt_mutex_slowunlock(struct rt_mutex *lock)
{ {
spin_lock(&lock->wait_lock); raw_spin_lock(&lock->wait_lock);
debug_rt_mutex_unlock(lock); debug_rt_mutex_unlock(lock);
@ -789,13 +789,13 @@ rt_mutex_slowunlock(struct rt_mutex *lock)
if (!rt_mutex_has_waiters(lock)) { if (!rt_mutex_has_waiters(lock)) {
lock->owner = NULL; lock->owner = NULL;
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
return; return;
} }
wakeup_next_waiter(lock); wakeup_next_waiter(lock);
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
/* Undo pi boosting if necessary: */ /* Undo pi boosting if necessary: */
rt_mutex_adjust_prio(current); rt_mutex_adjust_prio(current);
@ -970,8 +970,8 @@ EXPORT_SYMBOL_GPL(rt_mutex_destroy);
void __rt_mutex_init(struct rt_mutex *lock, const char *name) void __rt_mutex_init(struct rt_mutex *lock, const char *name)
{ {
lock->owner = NULL; lock->owner = NULL;
spin_lock_init(&lock->wait_lock); raw_spin_lock_init(&lock->wait_lock);
plist_head_init(&lock->wait_list, &lock->wait_lock); plist_head_init_raw(&lock->wait_list, &lock->wait_lock);
debug_rt_mutex_init(lock, name); debug_rt_mutex_init(lock, name);
} }
@ -1032,7 +1032,7 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
{ {
int ret; int ret;
spin_lock(&lock->wait_lock); raw_spin_lock(&lock->wait_lock);
mark_rt_mutex_waiters(lock); mark_rt_mutex_waiters(lock);
@ -1040,7 +1040,7 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
/* We got the lock for task. */ /* We got the lock for task. */
debug_rt_mutex_lock(lock); debug_rt_mutex_lock(lock);
rt_mutex_set_owner(lock, task, 0); rt_mutex_set_owner(lock, task, 0);
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
rt_mutex_deadlock_account_lock(lock, task); rt_mutex_deadlock_account_lock(lock, task);
return 1; return 1;
} }
@ -1056,7 +1056,7 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
*/ */
ret = 0; ret = 0;
} }
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
debug_rt_mutex_print_deadlock(waiter); debug_rt_mutex_print_deadlock(waiter);
@ -1106,7 +1106,7 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock,
{ {
int ret; int ret;
spin_lock(&lock->wait_lock); raw_spin_lock(&lock->wait_lock);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
@ -1124,7 +1124,7 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock,
*/ */
fixup_rt_mutex_waiters(lock); fixup_rt_mutex_waiters(lock);
spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
/* /*
* Readjust priority, when we did not get the lock. We might have been * Readjust priority, when we did not get the lock. We might have been