All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] cputime,cpuacct: Include guest time in user time in cpuacct.stat
@ 2021-02-17 12:00 Andrey Ryabinin
  2021-02-17 12:00 ` [PATCH 3/4] sched/cpuacct: fix user/system in shown cpuacct.usage* Andrey Ryabinin
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Andrey Ryabinin @ 2021-02-17 12:00 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Tejun Heo, Zefan Li, Johannes Weiner, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira
  Cc: Boris Burkov, Bharata B Rao, cgroups, linux-kernel,
	Andrey Ryabinin, stable

cpuacct.stat in no-root cgroups shows user time without guest time
included int it. This doesn't match with user time shown in root
cpuacct.stat and /proc/<pid>/stat.

Make account_guest_time() to add user time to cgroup's cpustat to
fix this.

Fixes: ef12fefabf94 ("cpuacct: add per-cgroup utime/stime statistics")
Signed-off-by: Andrey Ryabinin <arbn@yandex-team.com>
Cc: <stable@vger.kernel.org>
---
 kernel/sched/cputime.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 5f611658eeab..95a9c5603d29 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -139,8 +139,6 @@ void account_user_time(struct task_struct *p, u64 cputime)
  */
 void account_guest_time(struct task_struct *p, u64 cputime)
 {
-	u64 *cpustat = kcpustat_this_cpu->cpustat;
-
 	/* Add guest time to process. */
 	p->utime += cputime;
 	account_group_user_time(p, cputime);
@@ -148,11 +146,11 @@ void account_guest_time(struct task_struct *p, u64 cputime)
 
 	/* Add guest time to cpustat. */
 	if (task_nice(p) > 0) {
-		cpustat[CPUTIME_NICE] += cputime;
-		cpustat[CPUTIME_GUEST_NICE] += cputime;
+		task_group_account_field(p, CPUTIME_NICE, cputime);
+		task_group_account_field(p, CPUTIME_GUEST_NICE, cputime);
 	} else {
-		cpustat[CPUTIME_USER] += cputime;
-		cpustat[CPUTIME_GUEST] += cputime;
+		task_group_account_field(p, CPUTIME_USER, cputime);
+		task_group_account_field(p, CPUTIME_GUEST, cputime);
 	}
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2021-09-10 19:03 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-17 12:00 [PATCH 1/4] cputime,cpuacct: Include guest time in user time in cpuacct.stat Andrey Ryabinin
2021-02-17 12:00 ` [PATCH 3/4] sched/cpuacct: fix user/system in shown cpuacct.usage* Andrey Ryabinin
2021-03-17 22:22   ` Daniel Jordan
     [not found]     ` <87r1kdl8se.fsf-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2021-08-20  9:37       ` Andrey Ryabinin
2021-08-20  9:37         ` Andrey Ryabinin
     [not found] ` <20210217120004.7984-1-arbn-XoJtRXgx1JtgGdypvdXH1w@public.gmane.org>
2021-02-17 12:00   ` [PATCH 2/4] cgroup: Fix 'usage_usec' time in root's cpu.stat Andrey Ryabinin
2021-02-17 12:00     ` Andrey Ryabinin
     [not found]     ` <20210217120004.7984-2-arbn-XoJtRXgx1JtgGdypvdXH1w@public.gmane.org>
2021-03-17 22:13       ` Daniel Jordan
2021-03-17 22:13         ` Daniel Jordan
2021-02-17 12:00   ` [PATCH 4/4] sched/cpuacct: Make user/system times in cpuacct.stat more precise Andrey Ryabinin
2021-02-17 12:00     ` Andrey Ryabinin
     [not found]     ` <20210217120004.7984-4-arbn-XoJtRXgx1JtgGdypvdXH1w@public.gmane.org>
2021-03-17 22:25       ` Daniel Jordan
2021-03-17 22:25         ` Daniel Jordan
2021-03-17 22:09   ` [PATCH 1/4] cputime,cpuacct: Include guest time in user time in cpuacct.stat Daniel Jordan
2021-03-17 22:09     ` Daniel Jordan
2021-08-20  9:37     ` Andrey Ryabinin
2021-08-20  9:40 ` [PATCH v2 1/5] cputime, cpuacct: " Andrey Ryabinin
     [not found]   ` <20210820094005.20596-1-arbn-XoJtRXgx1JtgGdypvdXH1w@public.gmane.org>
2021-08-20  9:40     ` [PATCH v2 2/5] cpuacct: convert BUG_ON() to WARN_ON_ONCE() Andrey Ryabinin
2021-08-20  9:40       ` Andrey Ryabinin
2021-08-20  9:40     ` [PATCH v2 3/5] cgroup: Fix 'usage_usec' time in root's cpu.stat Andrey Ryabinin
2021-08-20  9:40       ` Andrey Ryabinin
2021-08-20  9:40     ` [PATCH v2 5/5] sched/cpuacct: Make user/system times in cpuacct.stat more precise Andrey Ryabinin
2021-08-20  9:40       ` Andrey Ryabinin
2021-08-20  9:40   ` [PATCH v2 4/5] sched/cpuacct: fix user/system in shown cpuacct.usage* Andrey Ryabinin
2021-09-10 19:03     ` Daniel Jordan
2021-09-07 17:19   ` [PATCH v2 1/5] cputime, cpuacct: Include guest time in user time in cpuacct.stat Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.