]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched/fair: Task based throttle time accounting
authorAaron Lu <ziqianlu@bytedance.com>
Fri, 29 Aug 2025 08:11:19 +0000 (16:11 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 3 Sep 2025 08:03:14 +0000 (10:03 +0200)
commiteb962f251fbba251a0d34897d6170f7616d70c52
treeb54f0837eedecb40e247ffeebce29868497293a7
parente1fad12dcb66b7f35573c52b665830a1538f9886
sched/fair: Task based throttle time accounting

With task based throttle model, the previous way to check cfs_rq's
nr_queued to decide if throttled time should be accounted doesn't work
as expected, e.g. when a cfs_rq which has a single task is throttled,
that task could later block in kernel mode instead of being dequeued on
limbo list and accounting this as throttled time is not accurate.

Rework throttle time accounting for a cfs_rq as follows:
- start accounting when the first task gets throttled in its hierarchy;
- stop accounting on unthrottle.

Note that there will be a time gap between when a cfs_rq is throttled
and when a task in its hierarchy is actually throttled. This accounting
mechanism only starts accounting in the latter case.

Suggested-by: Chengming Zhou <chengming.zhou@linux.dev> # accounting mechanism
Co-developed-by: K Prateek Nayak <kprateek.nayak@amd.com> # simplify implementation
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Aaron Lu <ziqianlu@bytedance.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Valentin Schneider <vschneid@redhat.com>
Tested-by: Matteo Martelli <matteo.martelli@codethink.co.uk>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lore.kernel.org/r/20250829081120.806-5-ziqianlu@bytedance.com
kernel/sched/fair.c
kernel/sched/sched.h