[tip: sched/core] sched/cache: Fix checking active load balance by only considering the CFS task

tip-bot2 for Chen Yu posted 1 patch 4 days, 14 hours ago
kernel/sched/fair.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[tip: sched/core] sched/cache: Fix checking active load balance by only considering the CFS task
Posted by tip-bot2 for Chen Yu 4 days, 14 hours ago
The following commit has been merged into the sched/core branch of tip:

Commit-ID:     d6b9afab44e23d537fb85ecf50330baaf9ec82e9
Gitweb:        https://git.kernel.org/tip/d6b9afab44e23d537fb85ecf50330baaf9ec82e9
Author:        Chen Yu <yu.c.chen@intel.com>
AuthorDate:    Wed, 13 May 2026 13:39:22 -07:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 18 May 2026 21:33:17 +02:00

sched/cache: Fix checking active load balance by only considering the CFS task

The currently running task cur may not be a CFS task, such as
an RT or Deadline task. For non-CFS tasks, the task_util(cur)
utilization average is not maintained, so this might pass a
stale or meaningless value to can_migrate_llc().

Check if the task is CFS before getting its task_util().

This bug was reported by sashiko.

Fixes: 714059f79ff0 ("sched/cache: Handle moving single tasks to/from their preferred LLC")
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Co-developed-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/f9161133cf040d286dca11344a112c5ef2a5253d.1778703694.git.tim.c.chen@linux.intel.com
---
 kernel/sched/fair.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 96c61ce..c249cae 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10509,7 +10509,8 @@ alb_break_llc(struct lb_env *env)
 	/*
 	 * All tasks prefer to stay on their current CPU.
 	 * Do not pull a task from its preferred CPU if:
-	 * 1. It is the only task running there(not too imbalance); OR
+	 * 1. It is the only task running and does not exceed
+	 *    imbalance allowance; OR
 	 * 2. Migrating it away from its preferred LLC would violate
 	 *    the cache-aware scheduling policy.
 	 */
@@ -10522,7 +10523,7 @@ alb_break_llc(struct lb_env *env)
 			return true;
 
 		cur = rcu_dereference_all(env->src_rq->curr);
-		if (cur)
+		if (cur && cur->sched_class == &fair_sched_class)
 			util = task_util(cur);
 
 		if (can_migrate_llc(env->src_cpu, env->dst_cpu,