diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 227c054eee24..7a0fd9d23838 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6223,6 +6223,23 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) #endif /* CONFIG_SCHED_CORE */ +static bool __task_can_run(struct task_struct *prev) +{ + if (__fatal_signal_pending(prev)) + return true; + + if (!frozen_or_skipped(prev)) + return true; + + /* + * We can't safely go back on the runqueue if we're an asymmetric + * task skipping the freezer. Doing so can lead to migration failures + * later on if there aren't any suitable CPUs left around for us to + * move to. + */ + return task_cpu_possible_mask(prev) == cpu_possible_mask; +} + /* * Constants for the sched_mode argument of __schedule(). * @@ -6334,7 +6351,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) */ prev_state = READ_ONCE(prev->__state); if (!(sched_mode & SM_MASK_PREEMPT) && prev_state) { - if (signal_pending_state(prev_state, prev)) { + if (signal_pending_state(prev_state, prev) && __task_can_run(prev)) { WRITE_ONCE(prev->__state, TASK_RUNNING); } else { prev->sched_contributes_to_load =