2021-02-17 12:10:46

by Andrey Ryabinin

[permalink] [raw]
Subject: [PATCH 2/4] cgroup: Fix 'usage_usec' time in root's cpu.stat

Global CPUTIME_USER counter already includes CPUTIME_GUEST
Also CPUTIME_NICE already includes CPUTIME_GUEST_NICE.

Remove additions of CPUTIME_GUEST[_NICE] to total ->sum_exec_runtime
to not account them twice.

Fixes: 936f2a70f207 ("cgroup: add cpu.stat file to root cgroup")
Signed-off-by: Andrey Ryabinin <[email protected]>
Cc: <[email protected]>
---
kernel/cgroup/rstat.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index d51175cedfca..89ca9b61aa0d 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -421,8 +421,6 @@ static void root_cgroup_cputime(struct task_cputime *cputime)
cputime->sum_exec_runtime += user;
cputime->sum_exec_runtime += sys;
cputime->sum_exec_runtime += cpustat[CPUTIME_STEAL];
- cputime->sum_exec_runtime += cpustat[CPUTIME_GUEST];
- cputime->sum_exec_runtime += cpustat[CPUTIME_GUEST_NICE];
}
}

--
2.26.2


2021-03-17 22:16:34

by Daniel Jordan

[permalink] [raw]
Subject: Re: [PATCH 2/4] cgroup: Fix 'usage_usec' time in root's cpu.stat

Andrey Ryabinin <[email protected]> writes:

> Global CPUTIME_USER counter already includes CPUTIME_GUEST
> Also CPUTIME_NICE already includes CPUTIME_GUEST_NICE.
>
> Remove additions of CPUTIME_GUEST[_NICE] to total ->sum_exec_runtime
> to not account them twice.

Yes, that's just wrong. usage_usec looks ok now.

Reviewed-by: Daniel Jordan <[email protected]>
Tested-by: Daniel Jordan <[email protected]>