mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
sched: Account cgroup CPU time to the execution context
Proxy execution separates the scheduling context from the execution context. Commitaa4f74dfd4("sched: Fix runtime accounting w/ split exec & sched contexts") made per-task and thread-group runtime accounting follow the task that actually executes, while cgroup CPU usage is charged to the donor. When the donor and execution task belong to different cgroups, this makes a task's execution time count against a different cgroup from the one the task belongs to. Cgroup CPU usage should follow the execution context, matching the per-task, thread-group, and cgroup user/system accounting. Keep scheduling state associated with the donor, but charge cgroup CPU usage to rq->curr. A reproducer with the donor and execution task in separate cgroups showed the execution task accumulating runtime while cgroup CPU usage was charged to the donor's cgroup. With this change, the execution task's cgroup accumulates the CPU usage instead. The same behavior was verified with an RT donor and with legacy cpuacct accounting. Fixes:aa4f74dfd4("sched: Fix runtime accounting w/ split exec & sched contexts") Suggested-by: Tejun Heo <tj@kernel.org> Signed-off-by: Hui Su <sh_def@163.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Tejun Heo <tj@kernel.org> Acked-by: John Stultz <jstultz@google.com> Link: https://patch.msgid.link/20260904034707.268416-1-sh_def@163.com
This commit is contained in:
parent
51b0e68cfa
commit
c23810313b
|
|
@ -1414,7 +1414,6 @@ static s64 update_se(struct rq *rq, struct sched_entity *se)
|
|||
|
||||
se->exec_start = now;
|
||||
if (entity_is_task(se)) {
|
||||
struct task_struct *donor = task_of(se);
|
||||
struct task_struct *running = rq->curr;
|
||||
/*
|
||||
* If se is a task, we account the time against the running
|
||||
|
|
@ -1427,8 +1426,7 @@ static s64 update_se(struct rq *rq, struct sched_entity *se)
|
|||
account_group_exec_runtime(running, delta_exec);
|
||||
account_mm_sched(rq, running, delta_exec);
|
||||
|
||||
/* cgroup time is always accounted against the donor */
|
||||
cgroup_account_cputime(donor, delta_exec);
|
||||
cgroup_account_cputime(running, delta_exec);
|
||||
} else {
|
||||
/* If not task, account the time against donor se */
|
||||
se->sum_exec_runtime += delta_exec;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user