From 3cb2d84065d8ddc30e153acef75a4ecd6abcdfed Mon Sep 17 00:00:00 2001 From: Puja Gupta Date: Wed, 13 Mar 2019 15:24:43 -0700 Subject: [PATCH] Revert "sched/deadline: Remove cpu_active_mask from cpudl_find()" This reverts commit 9659e1ee. The change leaves a possibility of scheduling dl task on offline cpu. The original commit text suggests that it should not be a problem since migrate_tasks() will take care of it, but there can be delay between marking cpu as offline and migrate_tasks() call since they are called on different hotplug notifications-offline happens on CPUHP_TEARDOWN_CPU while migrate_tasks() gets called on CPUHP_AP_SCHED_STARTING. And in between this duration there is a chance the dl task can get scheduled on this offline cpu and lead to BUG_ON. Hence revert the change. Change-Id: I6f4ea10d2ce4e83e12d36b9b90b1b630ffe4fc74 [pujag@codeaurora.org: fix minor conflicts due to reorg of the code] Signed-off-by: Puja Gupta --- kernel/sched/cpudeadline.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 50316455ea66..46c1b5e41edf 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -124,7 +124,8 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, const struct sched_dl_entity *dl_se = &p->dl; if (later_mask && - cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed)) { + cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed) && + cpumask_and(later_mask, later_mask, cpu_active_mask)) { return 1; } else { int best_cpu = cpudl_maximum(cp); @@ -132,6 +133,7 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, WARN_ON(best_cpu != -1 && !cpu_present(best_cpu)); if (cpumask_test_cpu(best_cpu, &p->cpus_allowed) && + cpumask_test_cpu(best_cpu, cpu_active_mask) && dl_time_before(dl_se->deadline, cp->elements[0].dl)) { if (later_mask) cpumask_set_cpu(best_cpu, later_mask);