Skip to content

Commit 868ad33

Browse files
KAGA-KOKOPeter Zijlstra
authored andcommitted
sched: Prevent balance_push() on remote runqueues
sched_setscheduler() and rt_mutex_setprio() invoke the run-queue balance callback after changing priorities or the scheduling class of a task. The run-queue for which the callback is invoked can be local or remote. That's not a problem for the regular rq::push_work which is serialized with a busy flag in the run-queue struct, but for the balance_push() work which is only valid to be invoked on the outgoing CPU that's wrong. It not only triggers the debug warning, but also leaves the per CPU variable push_work unprotected, which can result in double enqueues on the stop machine list. Remove the warning and validate that the function is invoked on the outgoing CPU. Fixes: ae79270 ("sched: Optimize finish_lock_switch()") Reported-by: Sebastian Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/87zgt1hdw7.ffs@tglx
1 parent 9848417 commit 868ad33

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/sched/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8523,17 +8523,17 @@ static void balance_push(struct rq *rq)
85238523
struct task_struct *push_task = rq->curr;
85248524

85258525
lockdep_assert_rq_held(rq);
8526-
SCHED_WARN_ON(rq->cpu != smp_processor_id());
85278526

85288527
/*
85298528
* Ensure the thing is persistent until balance_push_set(.on = false);
85308529
*/
85318530
rq->balance_callback = &balance_push_callback;
85328531

85338532
/*
8534-
* Only active while going offline.
8533+
* Only active while going offline and when invoked on the outgoing
8534+
* CPU.
85358535
*/
8536-
if (!cpu_dying(rq->cpu))
8536+
if (!cpu_dying(rq->cpu) || rq != this_rq())
85378537
return;
85388538

85398539
/*

0 commit comments

Comments
 (0)