From: tip-bot for Hiroshi Shimamoto <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
tglx@linutronix.de, efault@gmx.de, peterz@infradead.org,
fweisbec@gmail.com, paulmck@linux.vnet.ibm.com,
cmetcalf@ezchip.com, h-shimamoto@ct.jp.nec.com, mingo@kernel.org,
hpa@zytor.com, lcapitulino@redhat.com, riel@redhat.com,
cl@linux.com
Subject: [tip:locking/core] sched/cputime: Fix invalid gtime in proc
Date: Fri, 4 Dec 2015 03:53:13 -0800 [thread overview]
Message-ID: <tip-2541117b0cf79977fa11a0d6e17d61010677bd7b@git.kernel.org> (raw)
In-Reply-To: <1447948054-28668-2-git-send-email-fweisbec@gmail.com>
Commit-ID: 2541117b0cf79977fa11a0d6e17d61010677bd7b
Gitweb: http://git.kernel.org/tip/2541117b0cf79977fa11a0d6e17d61010677bd7b
Author: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
AuthorDate: Thu, 19 Nov 2015 16:47:28 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 4 Dec 2015 10:18:49 +0100
sched/cputime: Fix invalid gtime in proc
/proc/stats shows invalid gtime when the thread is running in guest.
When vtime accounting is not enabled, we cannot get a valid delta.
The delta is calculated with now - tsk->vtime_snap, but tsk->vtime_snap
is only updated when vtime accounting is runtime enabled.
This patch makes task_gtime() just return gtime without computing the
buggy non-existing tickless delta when vtime accounting is not enabled.
Use context_tracking_is_enabled() to check if vtime is accounting on
some cpu, in which case only we need to check the tickless delta. This
way we fix the gtime value regression on machines not running nohz full.
The kernel config contains CONFIG_VIRT_CPU_ACCOUNTING_GEN=y and
CONFIG_NO_HZ_FULL_ALL=n and boot without nohz_full.
I ran and stop a busy loop in VM and see the gtime in host.
Dump the 43rd field which shows the gtime in every second:
# while :; do awk '{print $3" "$43}' /proc/3955/task/4014/stat; sleep 1; done
S 4348
R 7064566
R 7064766
R 7064967
R 7065168
S 4759
S 4759
During running busy loop, it returns large value.
After applying this patch, we can see right gtime.
# while :; do awk '{print $3" "$43}' /proc/10913/task/10956/stat; sleep 1; done
S 5338
R 5365
R 5465
R 5566
R 5666
S 5726
S 5726
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1447948054-28668-2-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/cputime.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 26a5446..05de80b 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -788,6 +788,9 @@ cputime_t task_gtime(struct task_struct *t)
unsigned int seq;
cputime_t gtime;
+ if (!context_tracking_is_enabled())
+ return t->gtime;
+
do {
seq = read_seqbegin(&t->vtime_seqlock);
next prev parent reply other threads:[~2015-12-04 11:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-19 15:47 [PATCH 0/7] cputime: A few tickless cputime accounting fixes and improvements Frederic Weisbecker
2015-11-19 15:47 ` [PATCH 1/7] cputime: Fix invalid gtime in proc Frederic Weisbecker
2015-12-04 11:53 ` tip-bot for Hiroshi Shimamoto [this message]
2015-12-07 16:21 ` [tip:locking/core] sched/cputime: " Frederic Weisbecker
2015-12-08 5:34 ` Ingo Molnar
2015-11-19 15:47 ` [PATCH 2/7] cputime: Remove extra cost in task_cputime Frederic Weisbecker
2015-12-04 11:55 ` [tip:sched/core] sched/cputime: Remove extra cost in task_cputime () tip-bot for Hiroshi Shimamoto
2015-11-19 15:47 ` [PATCH 3/7] cputime: Clarify vtime symbols and document them Frederic Weisbecker
2015-12-04 11:55 ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2015-11-19 15:47 ` [PATCH 4/7] cputime: Correctly handle task guest time on housekeepers Frederic Weisbecker
2015-12-04 11:55 ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2015-11-19 15:47 ` [PATCH 5/7] cputime: Rename vtime_accounting_enabled to vtime_accounting_cpu_enabled Frederic Weisbecker
2015-12-04 11:56 ` [tip:sched/core] sched/cputime: Rename vtime_accounting_enabled() to vtime_accounting_cpu_enabled() tip-bot for Frederic Weisbecker
2015-11-19 15:47 ` [PATCH 6/7] cputime: Introduce vtime accounting check for readers Frederic Weisbecker
2015-11-19 20:28 ` Peter Zijlstra
2015-11-23 14:19 ` Frederic Weisbecker
2015-11-23 14:35 ` Peter Zijlstra
2015-11-23 15:22 ` Frederic Weisbecker
2015-12-04 11:56 ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2015-11-19 15:47 ` [PATCH 7/7] cputime: Convert vtime_seqlock to seqcount Frederic Weisbecker
2015-12-04 11:56 ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-2541117b0cf79977fa11a0d6e17d61010677bd7b@git.kernel.org \
--to=tipbot@zytor.com \
--cc=cl@linux.com \
--cc=cmetcalf@ezchip.com \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=h-shimamoto@ct.jp.nec.com \
--cc=hpa@zytor.com \
--cc=lcapitulino@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox