]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
timer-handle-idle-trylock-in-get-next-timer-irq.patch
authorThomas Gleixner <tglx@linutronix.de>
Sun, 17 Jul 2011 20:08:38 +0000 (22:08 +0200)
committerMichal Sojka <sojka@merica.cz>
Sun, 13 Sep 2015 07:47:24 +0000 (09:47 +0200)
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/spinlock_rt.h
kernel/locking/rtmutex.c
kernel/time/timer.c

index 5b6accddf61c54d0cdc853d8576671cf0e6c367f..ca08d3b2d9e88f6ddd21544350668799cc7b2315 100644 (file)
@@ -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)              \
index 02e1f2eab74110b5b0d6ff688c0e396d16e45017..f7ab4e2c34fa559c5ddf999c5bf1aaea9c570945 100644 (file)
@@ -1135,15 +1135,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);
index 5c8b912c2cfd389cf99a32c9d6853648741c12ac..1246eefdea5f50d49fdaa865fa93d2eab3ea7948 100644 (file)
@@ -1411,9 +1411,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);
@@ -1423,7 +1424,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;