]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched: Update rq->avg_idle when a task is moved to an idle CPU
authorShubhang Kaushik <shubhang@os.amperecomputing.com>
Wed, 21 Jan 2026 09:31:53 +0000 (01:31 -0800)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 22 Jan 2026 10:11:21 +0000 (11:11 +0100)
commit4b603f1551a73e2868b9e7a14b3938c23275cefb
treeadf475af4e511b745f250cf6b307d7f09f323027
parentbb332a9e5a057d2cb9b90e307b26cce9b1f6f660
sched: Update rq->avg_idle when a task is moved to an idle CPU

Currently, rq->idle_stamp is only used to calculate avg_idle during
wakeups. This means other paths that move a task to an idle CPU such as
fork/clone, execve, or migrations, do not end the CPU's idle status in
the scheduler's eyes, leading to an inaccurate avg_idle.

This patch introduces update_rq_avg_idle() to provide a more accurate
measurement of CPU idle duration. By invoking this helper in
put_prev_task_idle(), we ensure avg_idle is updated whenever a CPU
stops being idle, regardless of how the new task arrived.

Testing on an 80-core Ampere Altra (ARMv8) with 6.19-rc5 baseline:
 - Hackbench : +7.2% performance gain at 16 threads.
 - Schbench: Reduced p99.9 tail latencies at high concurrency.

Signed-off-by: Shubhang Kaushik <shubhang@os.amperecomputing.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Tested-by: Shubhang Kaushik <shubhang@os.amperecomputing.com>
Link: https://patch.msgid.link/20260121-v8-patch-series-v8-1-b7f1cbee5055@os.amperecomputing.com
kernel/sched/core.c
kernel/sched/idle.c
kernel/sched/sched.h