From: tip-bot for Frederic Weisbecker <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: h-shimamoto@ct.jp.nec.com, lcapitulino@redhat.com,
fweisbec@gmail.com, efault@gmx.de, cl@linux.com,
torvalds@linux-foundation.org, hpa@zytor.com, mingo@kernel.org,
cmetcalf@ezchip.com, peterz@infradead.org, tglx@linutronix.de,
riel@redhat.com, paulmck@linux.vnet.ibm.com,
linux-kernel@vger.kernel.org
Subject: [tip:sched/core] sched/cputime: Introduce vtime accounting check for readers
Date: Fri, 4 Dec 2015 03:56:26 -0800 [thread overview]
Message-ID: <tip-e592539466380279a9e6e6fdfe4545aa54f22593@git.kernel.org> (raw)
In-Reply-To: <1447948054-28668-7-git-send-email-fweisbec@gmail.com>
Commit-ID: e592539466380279a9e6e6fdfe4545aa54f22593
Gitweb: http://git.kernel.org/tip/e592539466380279a9e6e6fdfe4545aa54f22593
Author: Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Thu, 19 Nov 2015 16:47:33 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 4 Dec 2015 10:34:45 +0100
sched/cputime: Introduce vtime accounting check for readers
Readers need to know if vtime runs at all on some CPU somewhere, this
is a fast-path check to determine if we need to check further the need
to add up any tickless cputime delta.
This fast path check uses context tracking state because vtime is tied
to context tracking as of now. This check appears to be confusing though
so lets use a vtime function that deals with context tracking details
in vtime implementation instead.
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: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.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-7-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/vtime.h | 13 ++++++++++++-
kernel/sched/cputime.c | 6 +++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/include/linux/vtime.h b/include/linux/vtime.h
index ca23e83..fa21969 100644
--- a/include/linux/vtime.h
+++ b/include/linux/vtime.h
@@ -17,9 +17,20 @@ static inline bool vtime_accounting_cpu_enabled(void) { return true; }
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
+/*
+ * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
+ * in that case and compute the tickless cputime.
+ * For now vtime state is tied to context tracking. We might want to decouple
+ * those later if necessary.
+ */
+static inline bool vtime_accounting_enabled(void)
+{
+ return context_tracking_is_enabled();
+}
+
static inline bool vtime_accounting_cpu_enabled(void)
{
- if (context_tracking_is_enabled()) {
+ if (vtime_accounting_enabled()) {
if (context_tracking_cpu_is_enabled())
return true;
}
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 5727217..9989c3f 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -788,7 +788,7 @@ cputime_t task_gtime(struct task_struct *t)
unsigned int seq;
cputime_t gtime;
- if (!context_tracking_is_enabled())
+ if (!vtime_accounting_enabled())
return t->gtime;
do {
@@ -853,7 +853,7 @@ void task_cputime(struct task_struct *t, cputime_t *utime, cputime_t *stime)
{
cputime_t udelta, sdelta;
- if (!context_tracking_is_enabled()) {
+ if (!vtime_accounting_enabled()) {
if (utime)
*utime = t->utime;
if (stime)
@@ -874,7 +874,7 @@ void task_cputime_scaled(struct task_struct *t,
{
cputime_t udelta, sdelta;
- if (!context_tracking_is_enabled()) {
+ if (!vtime_accounting_enabled()) {
if (utimescaled)
*utimescaled = t->utimescaled;
if (stimescaled)
next prev parent reply other threads:[~2015-12-04 11:57 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:locking/core] sched/cputime: " tip-bot for Hiroshi Shimamoto
2015-12-07 16:21 ` 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-bot for Frederic Weisbecker [this message]
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-e592539466380279a9e6e6fdfe4545aa54f22593@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