diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
index 7b386e8..9201866 100644
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -13,7 +13,14 @@
 static int
 select_task_rq_stop(struct task_struct *p, int sd_flag, int flags)
 {
-	return task_cpu(p); /* stop tasks as never migrate */
+	int ccpu, cpu , dcpu;
+	ccpu = cpu = task_cpu(p);
+	if (unlikely(!cpumask_test_cpu(cpu, tsk_cpus_allowed(p)))) {
+		cpu = cpumask_first(tsk_cpus_allowed(p));
+		if (cpu >= nr_cpu_ids)
+			cpu = ccpu;
+	}
+	return cpu;
 }
 #endif /* CONFIG_SMP */
 
