[PATCH 2/2] sched/fair: Complete the bail-out list in can_migrate_task()

From: Zhan Xusheng

Date: Fri Aug 28 2026 - 04:37:09 EST


From: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>

can_migrate_task() decides whether load balancing may move a task off the
busiest runqueue. A comment at its head summarises the cases in which it
refuses, so that the tests below can be read against it.

The summary lists six cases, but there are eight, and they are not in the
order the tests are made. Two are absent:
commit 9bcb959d05ee ("sched/fair: Ignore percpu threads for imbalance
pulls") added the kthread_is_per_cpu() test, and
commit 873199d27bb2 ("sched/core: Prioritize migrating eligible tasks in
sched_balance_rq()") added the eligibility test, neither extending the
summary. Both tests do carry a local comment, so it is only the summary
that is short.

Add the two missing cases and order the list as the tests are made.

Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
---
kernel/sched/fair.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6ea87316d162..3587515ecbf6 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10848,10 +10848,12 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
* We do not migrate tasks that are:
* 1) delayed dequeued unless we migrate load, or
* 2) target cfs_rq is in throttled hierarchy, or
- * 3) cannot be migrated to this CPU due to cpus_ptr, or
- * 4) running (obviously), or
- * 5) are cache-hot on their current CPU, or
- * 6) are blocked on mutexes (if SCHED_PROXY_EXEC is enabled)
+ * 3) ineligible, while this domain has not failed to balance yet, or
+ * 4) per-CPU kthreads, or
+ * 5) blocked on mutexes (if SCHED_PROXY_EXEC is enabled), or
+ * 6) cannot be migrated to this CPU due to cpus_ptr, or
+ * 7) running (obviously), or
+ * 8) are cache-hot on their current CPU
*/
if ((p->se.sched_delayed) && (env->migration_type != migrate_load))
return 0;
--
2.43.0