summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2011-07-17 20:08:38 (GMT)
committerScott Wood <scottwood@freescale.com>2015-02-13 22:20:46 (GMT)
commit0623bc2dddc5fef9659d652cede0af467e437473 (patch)
treee351ea0d8d6229446d39e6cafceb4e51c1d8d387
parent1aa3f1a3a6b35843dc824e8aaad6420d476e5dcd (diff)
downloadlinux-fsl-qoriq-0623bc2dddc5fef9659d652cede0af467e437473.tar.xz
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.h12
-rw-r--r--kernel/rtmutex.c7
-rw-r--r--kernel/timer.c9
3 files changed, 19 insertions, 9 deletions
diff --git a/include/linux/spinlock_rt.h b/include/linux/spinlock_rt.h
index 621d857..447c457 100644
--- a/include/linux/spinlock_rt.h
+++ b/include/linux/spinlock_rt.h
@@ -50,7 +50,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 f78bbcd..82d1708 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -1027,15 +1027,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 f04db01..abfa2e4 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1386,9 +1386,10 @@ 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))
return now + 1;
#else
spin_lock(&base->lock);
@@ -1398,7 +1399,11 @@ unsigned long get_next_timer_interrupt(unsigned long now)
base->next_timer = __next_timer_interrupt(base);
expires = base->next_timer;
}
+#ifdef CONFIG_PREEMPT_RT_FULL
+ rt_spin_unlock(&base->lock);
+#else
spin_unlock(&base->lock);
+#endif
if (time_before_eq(expires, now))
return now;