From 45b8775b62bb27f5e88b07c17f45dd9ab0cf9bd9 Mon Sep 17 00:00:00 2001 From: Olav Haugan Date: Tue, 8 Nov 2016 17:06:21 -0800 Subject: [PATCH] sched/core: Fix migrate tasks bail-out condition Migrate tasks function is used by both hotplug and cpu isolation. During hotplug all the cpus are stalled (in stop machine) while tasks are being migrated. However, this is not the case during cpu isolation. A task that was counted as a pinned thread might have been migrated off the cpu. Take this into account when checking whether we have completed moving all tasks off the runqueue. Also ignore warning about tasks moving off the run-queue for isolation use case. Change-Id: I5c5f25eb9b1eaf0605b606a65e0ac86996fa5f27 Signed-off-by: Olav Haugan --- kernel/sched/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index e7196c3a3457..862eb8fd3860 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5497,7 +5497,7 @@ static void migrate_tasks(struct rq *dead_rq, bool migrate_pinned_tasks) */ if ((migrate_pinned_tasks && rq->nr_running == 1) || (!migrate_pinned_tasks && - rq->nr_running == num_pinned_kthreads)) + rq->nr_running <= num_pinned_kthreads)) break; /* @@ -5533,8 +5533,12 @@ static void migrate_tasks(struct rq *dead_rq, bool migrate_pinned_tasks) * Since we're inside stop-machine, _nothing_ should have * changed the task, WARN if weird stuff happened, because in * that case the above rq->lock drop is a fail too. + * However, during cpu isolation the load balancer might have + * interferred since we don't stop all CPUs. Ignore warning for + * this case. */ - if (WARN_ON(task_rq(next) != rq || !task_on_rq_queued(next))) { + if (WARN_ON((task_rq(next) != rq || !task_on_rq_queued(next)) && + migrate_pinned_tasks)) { raw_spin_unlock(&next->pi_lock); continue; }