Messages in this thread Patch in this message | | | From | Hiroshi Shimamoto <> | Subject | [PATCH v3 2/2] cputime: remove extra cost in task_cputime | Date | Fri, 30 Oct 2015 00:48:10 +0000 |
| |
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
| |