Merge branch 'linus' into sched/core
[linux-flexiantxendom0.git] / kernel / sched.c
index fde6ff9..b0e7ad7 100644 (file)
 
 static inline int rt_policy(int policy)
 {
-       if (unlikely(policy == SCHED_FIFO || policy == SCHED_RR))
+       if (policy == SCHED_FIFO || policy == SCHED_RR)
                return 1;
        return 0;
 }
@@ -2497,7 +2497,7 @@ ttwu_do_wakeup(struct rq *rq, struct task_struct *p, int wake_flags)
        if (p->sched_class->task_woken)
                p->sched_class->task_woken(rq, p);
 
-       if (unlikely(rq->idle_stamp)) {
+       if (rq->idle_stamp) {
                u64 delta = rq->clock - rq->idle_stamp;
                u64 max = 2*sysctl_sched_migration_cost;
 
@@ -2886,7 +2886,7 @@ void sched_fork(struct task_struct *p)
 #if defined(CONFIG_SMP)
        p->on_cpu = 0;
 #endif
-#ifdef CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT_COUNT
        /* Want to start with kernel preemption disabled. */
        task_thread_info(p)->preempt_count = 1;
 #endif
@@ -4338,11 +4338,8 @@ EXPORT_SYMBOL(schedule);
 
 static inline bool owner_running(struct mutex *lock, struct task_struct *owner)
 {
-       bool ret = false;
-
-       rcu_read_lock();
        if (lock->owner != owner)
-               goto fail;
+               return false;
 
        /*
         * Ensure we emit the owner->on_cpu, dereference _after_ checking
@@ -4352,11 +4349,7 @@ static inline bool owner_running(struct mutex *lock, struct task_struct *owner)
         */
        barrier();
 
-       ret = owner->on_cpu;
-fail:
-       rcu_read_unlock();
-
-       return ret;
+       return owner->on_cpu;
 }
 
 /*
@@ -4368,21 +4361,21 @@ int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner)
        if (!sched_feat(OWNER_SPIN))
                return 0;
 
+       rcu_read_lock();
        while (owner_running(lock, owner)) {
                if (need_resched())
-                       return 0;
+                       break;
 
                arch_mutex_cpu_relax();
        }
+       rcu_read_unlock();
 
        /*
-        * If the owner changed to another task there is likely
-        * heavy contention, stop spinning.
+        * We break out the loop above on need_resched() and when the
+        * owner changed, which is a sign for heavy contention. Return
+        * success only when lock->owner is NULL.
         */
-       if (lock->owner)
-               return 0;
-
-       return 1;
+       return lock->owner == NULL;
 }
 #endif
 
@@ -8185,7 +8178,7 @@ void __init sched_init(void)
        scheduler_running = 1;
 }
 
-#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
 static inline int preempt_count_equals(int preempt_offset)
 {
        int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
@@ -8195,7 +8188,6 @@ static inline int preempt_count_equals(int preempt_offset)
 
 void __might_sleep(const char *file, int line, int preempt_offset)
 {
-#ifdef in_atomic
        static unsigned long prev_jiffy;        /* ratelimiting */
 
        if ((preempt_count_equals(preempt_offset) && !irqs_disabled()) ||
@@ -8217,7 +8209,6 @@ void __might_sleep(const char *file, int line, int preempt_offset)
        if (irqs_disabled())
                print_irqtrace_events(current);
        dump_stack();
-#endif
 }
 EXPORT_SYMBOL(__might_sleep);
 #endif