Skip to content

Commit 22f667c

Browse files
author
Peter Zijlstra
committed
sched: Don't run cpu-online with balance_push() enabled
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]
1 parent 547a77d commit 22f667c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

kernel/sched/core.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7320,10 +7320,12 @@ static void balance_push_set(int cpu, bool on)
73207320
struct rq_flags rf;
73217321

73227322
rq_lock_irqsave(rq, &rf);
7323-
if (on)
7323+
if (on) {
7324+
WARN_ON_ONCE(rq->balance_callback);
73247325
rq->balance_callback = &balance_push_callback;
7325-
else
7326+
} else if (rq->balance_callback == &balance_push_callback) {
73267327
rq->balance_callback = NULL;
7328+
}
73277329
rq_unlock_irqrestore(rq, &rf);
73287330
}
73297331

@@ -7441,6 +7443,10 @@ int sched_cpu_activate(unsigned int cpu)
74417443
struct rq *rq = cpu_rq(cpu);
74427444
struct rq_flags rf;
74437445

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

74467452
#ifdef CONFIG_SCHED_SMT
@@ -7608,6 +7614,12 @@ int sched_cpu_dying(unsigned int cpu)
76087614
}
76097615
rq_unlock_irqrestore(rq, &rf);
76107616

7617+
/*
7618+
* Now that the CPU is offline, make sure we're welcome
7619+
* to new tasks once we come back up.
7620+
*/
7621+
balance_push_set(cpu, false);
7622+
76117623
calc_load_migrate(rq);
76127624
update_max_interval();
76137625
nohz_balance_exit_idle(rq);

0 commit comments

Comments
 (0)