Merge tag 'v5.11' into sched/core, to pick up fixes & refresh the branch
authorIngo Molnar <mingo@kernel.org>
Wed, 17 Feb 2021 13:04:39 +0000 (14:04 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 17 Feb 2021 13:04:39 +0000 (14:04 +0100)
Signed-off-by: Ingo Molnar <mingo@kernel.org>
1  2 
init/Kconfig
kernel/sched/core.c
kernel/sched/sched.h

diff --cc init/Kconfig
Simple merge
@@@ -7596,17 -7509,23 +7623,29 @@@ int sched_cpu_deactivate(unsigned int c
        struct rq_flags rf;
        int ret;
  
 +      /*
 +       * Remove CPU from nohz.idle_cpus_mask to prevent participating in
 +       * load balancing when not active
 +       */
 +      nohz_balance_exit_idle(rq);
 +
        set_cpu_active(cpu, false);
+       /*
+        * From this point forward, this CPU will refuse to run any task that
+        * is not: migrate_disable() or KTHREAD_IS_PER_CPU, and will actively
+        * push those tasks away until this gets cleared, see
+        * sched_cpu_dying().
+        */
+       balance_push_set(cpu, true);
        /*
-        * We've cleared cpu_active_mask, wait for all preempt-disabled and RCU
-        * users of this state to go away such that all new such users will
-        * observe it.
+        * We've cleared cpu_active_mask / set balance_push, wait for all
+        * preempt-disabled and RCU users of this state to go away such that
+        * all new such users will observe it.
+        *
+        * Specifically, we rely on ttwu to no longer target this CPU, see
+        * ttwu_queue_cond() and is_cpu_allowed().
         *
         * Do sync before park smpboot threads to take care the rcu boost case.
         */
@@@ -7703,11 -7639,21 +7759,20 @@@ int sched_cpu_dying(unsigned int cpu
        sched_tick_stop(cpu);
  
        rq_lock_irqsave(rq, &rf);
-       BUG_ON(rq->nr_running != 1 || rq_has_pinned_tasks(rq));
+       if (rq->nr_running != 1 || rq_has_pinned_tasks(rq)) {
+               WARN(true, "Dying CPU not properly vacated!");
+               dump_rq_tasks(rq, KERN_WARNING);
+       }
        rq_unlock_irqrestore(rq, &rf);
  
+       /*
+        * Now that the CPU is offline, make sure we're welcome
+        * to new tasks once we come back up.
+        */
+       balance_push_set(cpu, false);
        calc_load_migrate(rq);
        update_max_interval();
 -      nohz_balance_exit_idle(rq);
        hrtick_clear(rq);
        return 0;
  }
Simple merge