[tip: sched/core] sched/fair: Drop idle recency from slow-path CPU selection

From: tip-bot2 for Christian Loehle

Date: Fri Sep 25 2026 - 06:59:50 EST


The following commit has been merged into the sched/core branch of tip:

Commit-ID: abe440b3770fce8eb8ee92a563dfb55a7b9a1c0e
Gitweb: https://git.kernel.org/tip/abe440b3770fce8eb8ee92a563dfb55a7b9a1c0e
Author: Christian Loehle <christian.loehle@xxxxxxx>
AuthorDate: Thu, 17 Sep 2026 16:39:14 +01:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Fri, 25 Sep 2026 12:45:58 +02:00

sched/fair: Drop idle recency from slow-path CPU selection

The slow-path CPU picker favours the most recently idle CPU as a proxy
for cache warmth.

A more recent idle stamp may make ongoing entry more likely. If entry
cannot be aborted, that CPU must finish entry and then exit, potentially
paying more than an already-resident CPU with the same advertised exit
latency. The advertised worst-case latency covers both cases. idle_stamp
does not timestamp the current CPUIdle entry, so this is only a heuristic.

A recent scheduler-idle transition may also mark a short gap in recurring
task activity, making the CPU likely to be busy again soon.

Drop the timestamp tie-break and retain the first candidate unless a
lower advertised exit latency is found.

Signed-off-by: Christian Loehle <christian.loehle@xxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Reviewed-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
Link: https://patch.msgid.link/20260917153915.1563875-2-christian.loehle@xxxxxxx
---
kernel/sched/fair.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a03e7f4..c4d4b55 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8444,7 +8444,6 @@ sched_balance_find_dst_group_cpu(struct sched_group *group, struct task_struct *
{
unsigned long load, min_load = ULONG_MAX;
unsigned int min_exit_latency = UINT_MAX;
- u64 latest_idle_timestamp = 0;
int least_loaded_cpu = this_cpu;
int shallowest_idle_cpu = -1;
int i;
@@ -8466,22 +8465,10 @@ sched_balance_find_dst_group_cpu(struct sched_group *group, struct task_struct *
if (available_idle_cpu(i)) {
struct cpuidle_state *idle = idle_get_state(rq);
if (idle && idle->exit_latency < min_exit_latency) {
- /*
- * We give priority to a CPU whose idle state
- * has the smallest exit latency irrespective
- * of any idle timestamp.
- */
min_exit_latency = idle->exit_latency;
- latest_idle_timestamp = rq->idle_stamp;
shallowest_idle_cpu = i;
} else if ((!idle || idle->exit_latency == min_exit_latency) &&
- rq->idle_stamp > latest_idle_timestamp) {
- /*
- * If equal or no active idle state, then
- * the most recently idled CPU might have
- * a warmer cache.
- */
- latest_idle_timestamp = rq->idle_stamp;
+ shallowest_idle_cpu == -1) {
shallowest_idle_cpu = i;
}
} else if (shallowest_idle_cpu == -1) {