diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-07-17 22:08:38 +0200 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2011-11-14 11:02:02 -0600 |
commit | e04435c5e581e50d5ef07f7c07f4da329aad2824 (patch) | |
tree | 8ca3ae55e14d1bc7021f094ae703789067985634 | |
parent | 3c287248be42a22006f11cd931db5230c0e4cd45 (diff) |
timer-handle-idle-trylock-in-get-next-timer-irq.patch
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | include/linux/spinlock_rt.h | 12 | ||||
-rw-r--r-- | kernel/rtmutex.c | 7 | ||||
-rw-r--r-- | kernel/timer.c | 7 |
3 files changed, 16 insertions, 10 deletions
diff --git a/include/linux/spinlock_rt.h b/include/linux/spinlock_rt.h index 205ca95a849e..3b555b4b52cf 100644 --- a/include/linux/spinlock_rt.h +++ b/include/linux/spinlock_rt.h @@ -51,7 +51,17 @@ extern void __lockfunc __rt_spin_unlock(struct rt_mutex *lock); #define spin_lock_irq(lock) spin_lock(lock) -#define spin_trylock(lock) __cond_lock(lock, rt_spin_trylock(lock)) +#define spin_do_trylock(lock) __cond_lock(lock, rt_spin_trylock(lock)) + +#define spin_trylock(lock) \ +({ \ + int __locked; \ + migrate_disable(); \ + __locked = spin_do_trylock(lock); \ + if (!__locked) \ + migrate_enable(); \ + __locked; \ +}) #ifdef CONFIG_LOCKDEP # define spin_lock_nested(lock, subclass) \ diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c index e19354169638..991bc7f2a437 100644 --- a/kernel/rtmutex.c +++ b/kernel/rtmutex.c @@ -860,15 +860,10 @@ EXPORT_SYMBOL(rt_spin_unlock_wait); int __lockfunc rt_spin_trylock(spinlock_t *lock) { - int ret; + int ret = rt_mutex_trylock(&lock->lock); - migrate_disable(); - ret = rt_mutex_trylock(&lock->lock); if (ret) spin_acquire(&lock->dep_map, 0, 1, _RET_IP_); - else - migrate_enable(); - return ret; } EXPORT_SYMBOL(rt_spin_trylock); diff --git a/kernel/timer.c b/kernel/timer.c index b22ea0b9c391..a9e8a46144a6 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1323,13 +1323,14 @@ unsigned long get_next_timer_interrupt(unsigned long now) /* * On PREEMPT_RT we cannot sleep here. If the trylock does not * succeed then we return the worst-case 'expires in 1 tick' - * value: + * value. We use the rt functions here directly to avoid a + * migrate_disable() call. */ - if (spin_trylock(&base->lock)) { + if (spin_do_trylock(&base->lock)) { if (time_before_eq(base->next_timer, base->timer_jiffies)) base->next_timer = __next_timer_interrupt(base); expires = base->next_timer; - spin_unlock(&base->lock); + rt_spin_unlock(&base->lock); } else { expires = now + 1; } |