[PATCH 1/2] sched/fair: Fix stale comment on task_is_ineligible_on_dst_cpu()
From: Zhan Xusheng
Date: Fri Aug 28 2026 - 04:36:43 EST
From: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
can_migrate_task() soft-limits the migration of ineligible tasks, and
task_is_ineligible_on_dst_cpu() is the test it uses. A comment above the
helper describes when the limit applies.
That comment matches neither the test that is made nor the runqueue it is
made on. It gives the condition as "dst_cfs_rq->nr_queued is greater than
1", while the code has always tested for a non-empty runqueue rather than
for more than one task, ever since commit 873199d27bb2 ("sched/core:
Prioritize migrating eligible tasks in sched_balance_rq()") added it. The
field it names is not the one read anymore either: since
commit 85570f10a4c6 ("sched/eevdf: Move to a single runqueue") dst_cfs_rq
is the root cfs_rq rather than the task group's on the destination cpu, the
count read is h_nr_queued, and eligibility is computed on
&task_rq(p)->cfs rather than task_cfs_rq(p). The comment was left as it
was.
Describe the test that is actually made, and record why eligibility is
evaluated on the source runqueue, which so far is only stated in the
changelog of the commit that introduced the helper.
Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
---
kernel/sched/fair.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6d881e530f89..6ea87316d162 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10521,12 +10521,13 @@ static inline long migrate_degrades_locality(struct task_struct *p,
#endif /* !CONFIG_NUMA_BALANCING */
/*
- * Check whether the task is ineligible on the destination cpu
+ * Check whether @p would be ineligible if migrated to @dest_cpu.
*
- * When the PLACE_LAG scheduling feature is enabled and
- * dst_cfs_rq->nr_queued is greater than 1, if the task
- * is ineligible, it will also be ineligible when
- * it is migrated to the destination cpu.
+ * Eligibility is evaluated on the source runqueue, because place_entity()
+ * preserves the lag over a migration: a task that is ineligible on the
+ * source stays ineligible on the destination. It only matters when the
+ * destination has something queued, as a task joining an empty runqueue is
+ * eligible either way.
*/
static inline int task_is_ineligible_on_dst_cpu(struct task_struct *p, int dest_cpu)
{
base-commit: 1b78070aaef63512688aebfbc82365ef9d6660f1
--
2.43.0