Skip to content

Commit

Permalink
sched: Don't run cpu-online with balance_push() enabled
Browse files Browse the repository at this point in the history
We don't need to push away tasks when we come online, mark the push
complete right before the CPU dies.

XXX hotplug state machine has trouble with rollback here.

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Valentin Schneider <[email protected]>
Tested-by: Valentin Schneider <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
Peter Zijlstra committed Jan 22, 2021
1 parent 547a77d commit 22f667c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -7320,10 +7320,12 @@ static void balance_push_set(int cpu, bool on)
struct rq_flags rf;

rq_lock_irqsave(rq, &rf);
if (on)
if (on) {
WARN_ON_ONCE(rq->balance_callback);
rq->balance_callback = &balance_push_callback;
else
} else if (rq->balance_callback == &balance_push_callback) {
rq->balance_callback = NULL;
}
rq_unlock_irqrestore(rq, &rf);
}

Expand Down Expand Up @@ -7441,6 +7443,10 @@ int sched_cpu_activate(unsigned int cpu)
struct rq *rq = cpu_rq(cpu);
struct rq_flags rf;

/*
* Make sure that when the hotplug state machine does a roll-back
* we clear balance_push. Ideally that would happen earlier...
*/
balance_push_set(cpu, false);

#ifdef CONFIG_SCHED_SMT
Expand Down Expand Up @@ -7608,6 +7614,12 @@ int sched_cpu_dying(unsigned int cpu)
}
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);
Expand Down

0 comments on commit 22f667c

Please sign in to comment.