Probably we do not need any checks. This task was picked by->pick_next_task(), it should have task_cpu(p) == dead_cpu ?

But. I think there is a problem. We should not migrate current task,stop thread, which does the migrating. At least, sched_stoptask.cdoesn't implement ->enqueue_task() and we can never wake it up laterfor kthread_stop().

Perhaps migrate_tasks() should do for_each_class() by hand toignore stop_sched_class. But then _cpu_down() should somewhowensure the stop thread on the dead CPU is already parked inschedule().