From: Ingo Molnar Date: Wed, 17 Feb 2021 13:04:39 +0000 (+0100) Subject: Merge tag 'v5.11' into sched/core, to pick up fixes & refresh the branch X-Git-Tag: v5.12-rc1~147^2~35 X-Git-Url: https://repo.jachan.dev/linux.git/commitdiff_plain/ed3cd45f8ca873dd320ff7e6b4c1c8f83a65302c Merge tag 'v5.11' into sched/core, to pick up fixes & refresh the branch Signed-off-by: Ingo Molnar --- ed3cd45f8ca873dd320ff7e6b4c1c8f83a65302c diff --cc kernel/sched/core.c index 06b449942adf,ff74fca39ed2..6c789dcb8e5a --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@@ -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; }