Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1259140 > unrolled thread

[PATCH v3 2/2] cputime: remove extra cost in task_cputime

Started byHiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
First post2015-10-30 01:50 +0100
Last post2015-10-30 01:50 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v3 2/2] cputime: remove extra cost in task_cputime Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> - 2015-10-30 01:50 +0100

#1259140 — [PATCH v3 2/2] cputime: remove extra cost in task_cputime

FromHiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Date2015-10-30 01:50 +0100
Subject[PATCH v3 2/2] cputime: remove extra cost in task_cputime
Message-ID<qp63g-7lc-13@gated-at.bofh.it>
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>

There is an extra cost in task_cputime() and task_cputime_scaled() when
nohz_full is not activated. This patch removes that cost. When vtime
accounting is not enabled, we don't need to get deltas of utime and stime
with seqlock.

This patch adds a shortcut route if vtime accounting is not enabled.

Use context_tracking_is_enabled() to check if the vtime accounting on
current cpu. In future we should check the state of cpu which is running
target thread.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: stable@vger.kernel.org
---
v3: this patch is newly added for related issue.

 kernel/sched/cputime.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 63904e7..ff0365d 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -851,6 +851,14 @@ void task_cputime(struct task_struct *t, cputime_t *utime, cputime_t *stime)
 {
 	cputime_t udelta, sdelta;
 
+	if (!context_tracking_is_enabled()) {
+		if (utime)
+			*utime = t->utime;
+		if (stime)
+			*stime = t->stime;
+		return;
+	}
+
 	fetch_task_cputime(t, utime, stime, &t->utime,
 			   &t->stime, &udelta, &sdelta);
 	if (utime)
@@ -864,6 +872,14 @@ void task_cputime_scaled(struct task_struct *t,
 {
 	cputime_t udelta, sdelta;
 
+	if (!context_tracking_is_enabled()) {
+		if (utimescaled)
+			*utimescaled = t->utimescaled;
+		if (stimescaled)
+			*stimescaled = t->stimescaled;
+		return;
+	}
+
 	fetch_task_cputime(t, utimescaled, stimescaled,
 			   &t->utimescaled, &t->stimescaled, &udelta, &sdelta);
 	if (utimescaled)
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web