Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / kernel / sched / core.c
index 0ca7d2d..15d2562 100644 (file)
@@ -4077,6 +4077,22 @@ static inline void finish_lock_switch(struct rq *rq)
 # define finish_arch_post_lock_switch()        do { } while (0)
 #endif
 
+static inline void kmap_local_sched_out(void)
+{
+#ifdef CONFIG_KMAP_LOCAL
+       if (unlikely(current->kmap_ctrl.idx))
+               __kmap_local_sched_out();
+#endif
+}
+
+static inline void kmap_local_sched_in(void)
+{
+#ifdef CONFIG_KMAP_LOCAL
+       if (unlikely(current->kmap_ctrl.idx))
+               __kmap_local_sched_in();
+#endif
+}
+
 /**
  * prepare_task_switch - prepare to switch tasks
  * @rq: the runqueue preparing to switch
@@ -4099,6 +4115,7 @@ prepare_task_switch(struct rq *rq, struct task_struct *prev,
        perf_event_task_sched_out(prev, next);
        rseq_preempt(prev);
        fire_sched_out_preempt_notifiers(prev, next);
+       kmap_local_sched_out();
        prepare_task(next);
        prepare_arch_switch(next);
 }
@@ -4165,6 +4182,14 @@ static struct rq *finish_task_switch(struct task_struct *prev)
        finish_lock_switch(rq);
        finish_arch_post_lock_switch();
        kcov_finish_switch(current);
+       /*
+        * kmap_local_sched_out() is invoked with rq::lock held and
+        * interrupts disabled. There is no requirement for that, but the
+        * sched out code does not have an interrupt enabled section.
+        * Restoring the maps on sched in does not require interrupts being
+        * disabled either.
+        */
+       kmap_local_sched_in();
 
        fire_sched_in_preempt_notifiers(current);
        /*
@@ -4805,6 +4830,7 @@ static inline void schedule_debug(struct task_struct *prev, bool preempt)
                preempt_count_set(PREEMPT_DISABLED);
        }
        rcu_sleep_check();
+       SCHED_WARN_ON(ct_state() == CONTEXT_USER);
 
        profile_hit(SCHED_PROFILING, __builtin_return_address(0));
 
@@ -5146,7 +5172,7 @@ void __sched schedule_idle(void)
        } while (need_resched());
 }
 
-#ifdef CONFIG_CONTEXT_TRACKING
+#if defined(CONFIG_CONTEXT_TRACKING) && !defined(CONFIG_HAVE_CONTEXT_TRACKING_OFFSTACK)
 asmlinkage __visible void __sched schedule_user(void)
 {
        /*