Merge branch 'sched/core' into core/mm
authorThomas Gleixner <tglx@linutronix.de>
Tue, 24 Nov 2020 10:26:11 +0000 (11:26 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 24 Nov 2020 10:26:11 +0000 (11:26 +0100)
Pull the migrate disable mechanics which is a prerequisite for preemptible
kmap_local().

1  2 
kernel/sched/cpufreq_schedutil.c
kernel/stop_machine.c

@@@ -102,8 -102,7 +102,8 @@@ static bool sugov_should_update_freq(st
  static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time,
                                   unsigned int next_freq)
  {
 -      if (sg_policy->next_freq == next_freq)
 +      if (sg_policy->next_freq == next_freq &&
 +          !cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS))
                return false;
  
        sg_policy->next_freq = next_freq;
@@@ -162,8 -161,7 +162,8 @@@ static unsigned int get_next_freq(struc
  
        freq = map_util_freq(util, freq, max);
  
 -      if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update)
 +      if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update &&
 +          !cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS))
                return sg_policy->next_freq;
  
        sg_policy->need_freq_update = false;
@@@ -901,16 -899,9 +901,9 @@@ struct cpufreq_governor *cpufreq_defaul
  cpufreq_governor_init(schedutil_gov);
  
  #ifdef CONFIG_ENERGY_MODEL
- extern bool sched_energy_update;
- extern struct mutex sched_energy_mutex;
  static void rebuild_sd_workfn(struct work_struct *work)
  {
-       mutex_lock(&sched_energy_mutex);
-       sched_energy_update = true;
-       rebuild_sched_domains();
-       sched_energy_update = false;
-       mutex_unlock(&sched_energy_mutex);
+       rebuild_sched_domains_energy();
  }
  static DECLARE_WORK(rebuild_sd_work, rebuild_sd_workfn);
  
diff --combined kernel/stop_machine.c
@@@ -42,11 -42,27 +42,27 @@@ struct cpu_stopper 
        struct list_head        works;          /* list of pending works */
  
        struct cpu_stop_work    stop_work;      /* for stop_cpus */
+       unsigned long           caller;
+       cpu_stop_fn_t           fn;
  };
  
  static DEFINE_PER_CPU(struct cpu_stopper, cpu_stopper);
  static bool stop_machine_initialized = false;
  
+ void print_stop_info(const char *log_lvl, struct task_struct *task)
+ {
+       /*
+        * If @task is a stopper task, it cannot migrate and task_cpu() is
+        * stable.
+        */
+       struct cpu_stopper *stopper = per_cpu_ptr(&cpu_stopper, task_cpu(task));
+       if (task != stopper->thread)
+               return;
+       printk("%sStopper: %pS <- %pS\n", log_lvl, stopper->fn, (void *)stopper->caller);
+ }
  /* static data for stop_cpus */
  static DEFINE_MUTEX(stop_cpus_mutex);
  static bool stop_cpus_in_progress;
@@@ -123,7 -139,7 +139,7 @@@ static bool cpu_stop_queue_work(unsigne
  int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg)
  {
        struct cpu_stop_done done;
-       struct cpu_stop_work work = { .fn = fn, .arg = arg, .done = &done };
+       struct cpu_stop_work work = { .fn = fn, .arg = arg, .done = &done, .caller = _RET_IP_ };
  
        cpu_stop_init_done(&done, 1);
        if (!cpu_stop_queue_work(cpu, &work))
@@@ -178,7 -194,7 +194,7 @@@ static void ack_state(struct multi_stop
                set_state(msdata, msdata->state + 1);
  }
  
 -void __weak stop_machine_yield(const struct cpumask *cpumask)
 +notrace void __weak stop_machine_yield(const struct cpumask *cpumask)
  {
        cpu_relax();
  }
@@@ -331,7 -347,8 +347,8 @@@ int stop_two_cpus(unsigned int cpu1, un
        work1 = work2 = (struct cpu_stop_work){
                .fn = multi_cpu_stop,
                .arg = &msdata,
-               .done = &done
+               .done = &done,
+               .caller = _RET_IP_,
        };
  
        cpu_stop_init_done(&done, 2);
  bool stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
                        struct cpu_stop_work *work_buf)
  {
-       *work_buf = (struct cpu_stop_work){ .fn = fn, .arg = arg, };
+       *work_buf = (struct cpu_stop_work){ .fn = fn, .arg = arg, .caller = _RET_IP_, };
        return cpu_stop_queue_work(cpu, work_buf);
  }
  
@@@ -487,6 -504,8 +504,8 @@@ repeat
                int ret;
  
                /* cpu stop callbacks must not sleep, make in_atomic() == T */
+               stopper->caller = work->caller;
+               stopper->fn = fn;
                preempt_count_inc();
                ret = fn(arg);
                if (done) {
                        cpu_stop_signal_done(done);
                }
                preempt_count_dec();
+               stopper->fn = NULL;
+               stopper->caller = 0;
                WARN_ONCE(preempt_count(),
                          "cpu_stop: %ps(%p) leaked preempt count\n", fn, arg);
                goto repeat;