mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cputime: fix invalid gtime
@ 2015-09-03  0:45 Hiroshi Shimamoto
  2015-09-17 11:11 ` Hiroshi Shimamoto
  2015-09-17 14:21 ` Peter Zijlstra
  0 siblings, 2 replies; 4+ messages in thread
From: Hiroshi Shimamoto @ 2015-09-03  0:45 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: linux-kernel

From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>

/proc/stats shows invalid gtime when the thread is running in guest.
When vtime accounting is not enabled, we cannot get a valid delta.

Just return gtime when vtime accounting is not enabled in task_gtime().

Before
10987 (qemu-kvm) S 1 10923 10923 0 -1 138428608 7521 0 90 0 3776 460 0 0 20 0 24 0 11960 8090398720 151288 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 9 0 0 0 3554 0 0 0 0 0 0 0 0 0
10987 (qemu-kvm) S 1 10923 10923 0 -1 138428608 7521 0 90 0 3776 460 0 0 20 0 17 0 11960 8031649792 150268 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 9 0 0 0 3554 0 0 0 0 0 0 0 0 0
10987 (qemu-kvm) R 1 10923 10923 0 -1 138428624 7521 0 90 0 3843 460 0 0 20 0 17 0 11960 8031649792 150268 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 9 0 0 0 21415 0 0 0 0 0 0 0 0 0
10987 (qemu-kvm) R 1 10923 10923 0 -1 138428624 7521 0 90 0 3943 460 0 0 20 0 17 0 11960 8031649792 150268 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 9 0 0 0 21616 0 0 0 0 0 0 0 0 0
10987 (qemu-kvm) R 1 10923 10923 0 -1 138428624 7521 0 90 0 4044 460 0 0 20 0 17 0 11960 8031649792 150268 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 9 0 0 0 21816 0 0 0 0 0 0 0 0 0
10987 (qemu-kvm) R 1 10923 10923 0 -1 138428624 7521 0 90 0 4144 460 0 0 20 0 17 0 11960 8031649792 150268 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 9 0 0 0 22017 0 0 0 0 0 0 0 0 0
10987 (qemu-kvm) R 1 10923 10923 0 -1 138428624 7521 0 90 0 4245 460 0 0 20 0 11 0 11960 7981293568 149758 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 9 0 0 0 22218 0 0 0 0 0 0 0 0 0
10987 (qemu-kvm) S 1 10923 10923 0 -1 138428608 7521 0 90 0 4308 460 0 0 20 0 11 0 11960 7981293568 149758 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 9 0 0 0 4084 0 0 0 0 0 0 0 0 0

After
10845 (qemu-kvm) S 1 10792 10792 0 -1 138428608 202 0 0 0 2858 30 0 0 20 0 29 0 7676 8511279104 148187 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 3 0 0 0 2874 0 0 0 0 0 0 0 0 0
10845 (qemu-kvm) S 1 10792 10792 0 -1 138428608 202 0 0 0 2858 30 0 0 20 0 29 0 7676 8511279104 148187 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 3 0 0 0 2874 0 0 0 0 0 0 0 0 0
10845 (qemu-kvm) R 1 10792 10792 0 -1 138428624 203 0 0 0 2936 30 0 0 20 0 29 0 7676 8511279104 148187 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 3 0 0 0 2952 0 0 0 0 0 0 0 0 0
10845 (qemu-kvm) R 1 10792 10792 0 -1 138428624 203 0 0 0 3037 30 0 0 20 0 29 0 7676 8511279104 152184 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 3 0 0 0 3052 0 0 0 0 0 0 0 0 0
10845 (qemu-kvm) R 1 10792 10792 0 -1 138428624 203 0 0 0 3137 30 0 0 20 0 29 0 7676 8511279104 152184 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 3 0 0 0 3152 0 0 0 0 0 0 0 0 0
10845 (qemu-kvm) R 1 10792 10792 0 -1 138428624 203 0 0 0 3237 30 0 0 20 0 27 0 7676 8511279104 152188 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 3 0 0 0 3252 0 0 0 0 0 0 0 0 0
10845 (qemu-kvm) S 1 10792 10792 0 -1 138428608 203 0 0 0 3262 31 0 0 20 0 11 0 7676 8393781248 151156 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 3 0 0 0 3277 0 0 0 0 0 0 0 0 0
10845 (qemu-kvm) S 1 10792 10792 0 -1 138428608 203 0 0 0 3262 31 0 0 20 0 11 0 7676 8393781248 151156 18446744073709551615 1 1 0 0 0 0 2147220671 4096 25155 18446744073709551615 0 0 -1 3 0 0 0 3277 0 0 0 0 0 0 0 0 0

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
 kernel/sched/cputime.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 8cbc3db..f614ee9 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -786,6 +786,9 @@ cputime_t task_gtime(struct task_struct *t)
 	unsigned int seq;
 	cputime_t gtime;
 
+	if (!vtime_accounting_enabled())
+		return t->gtime;
+
 	do {
 		seq = read_seqbegin(&t->vtime_seqlock);
 
-- 
1.8.3.1


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

end of thread, other threads:[~2015-09-17 23:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-03  0:45 [PATCH] cputime: fix invalid gtime Hiroshi Shimamoto
2015-09-17 11:11 ` Hiroshi Shimamoto
2015-09-17 14:21 ` Peter Zijlstra
2015-09-17 23:47   ` Hiroshi Shimamoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome