Upgrade to 4.4.50-rt62
[kvmfornfv.git] / kernel / arch / x86 / include / asm / preempt.h
index 5dbd2d0..6f432ad 100644 (file)
@@ -89,6 +89,8 @@ static __always_inline bool __preempt_count_dec_and_test(void)
        if (____preempt_count_dec_and_test())
                return true;
 #ifdef CONFIG_PREEMPT_LAZY
+       if (current_thread_info()->preempt_lazy_count)
+               return false;
        return test_thread_flag(TIF_NEED_RESCHED_LAZY);
 #else
        return false;
@@ -101,8 +103,19 @@ static __always_inline bool __preempt_count_dec_and_test(void)
 static __always_inline bool should_resched(int preempt_offset)
 {
 #ifdef CONFIG_PREEMPT_LAZY
-       return unlikely(raw_cpu_read_4(__preempt_count) == preempt_offset ||
-                       test_thread_flag(TIF_NEED_RESCHED_LAZY));
+       u32 tmp;
+
+       tmp = raw_cpu_read_4(__preempt_count);
+       if (tmp == preempt_offset)
+               return true;
+
+       /* preempt count == 0 ? */
+       tmp &= ~PREEMPT_NEED_RESCHED;
+       if (tmp)
+               return false;
+       if (current_thread_info()->preempt_lazy_count)
+               return false;
+       return test_thread_flag(TIF_NEED_RESCHED_LAZY);
 #else
        return unlikely(raw_cpu_read_4(__preempt_count) == preempt_offset);
 #endif