From 44d528b138d9887931e045e8d867dbefbdfcf3d3 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 [satyap@codeaurora.org: resolve trivial merge conflicts] Signed-off-by: Satya Durga Srinivasu Prabhala --- 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 5cc4012572ec..0346837fac83 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -120,7 +120,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_ptr)) { + cpumask_and(later_mask, cp->free_cpus, p->cpus_ptr) && + cpumask_and(later_mask, later_mask, cpu_active_mask)) { return 1; } else { int best_cpu = cpudl_maximum(cp); @@ -128,6 +129,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_ptr) && + 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);