Re: [PATCH] sched/cputime: Account cgroup fields to the scheduling context

From: Tejun Heo

Date: Thu Sep 03 2026 - 13:35:13 EST


Hello, Hui.

On Thu, Sep 03, 2026 at 07:07:12PM +0800, Hui Su wrote:
> Proxy execution separates the scheduling context from the execution
> context. Scheduler runtime accounting charges cgroup time to the donor,
> while tick and vtime accounting use the execution task when updating
> cgroup fields.
>
> When the donor and execution task belong to different cgroups, this can
> charge cpu.stat usage to the donor cgroup while charging cpu.stat user
> and system fields to the execution task's cgroup.
>
> Before this fix, a reproducer with donor and execution tasks in separate
> cgroups showed the donor cgroup gaining usage time while the execution
> cgroup gained system time.

When these numbers are presented to the userspace, the user/sys split is
calculated out of usage_usec, so at least the presented numbers should be
coherent no matter what.

> Account cgroup fields to the scheduling context as well. Separate
> per-CPU cpustat accounting from cgroup field accounting so the former
> continues to follow the execution context while the latter follows the
> scheduling context.

I don't think it makes sense for cgroup's usage times to deviate from how
thread's get reported. Threads follow execution context. All cgroup numbers
should too. If you're worried about usage_usec not agreeing with e.g.
bandwidth control results, we can show donation time separately, but let's
worry about that later.

Thanks.

--
tejun