diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2012-11-13 08:20:55 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2013-01-27 13:23:31 -0500 |
commit | 6fac4829ce0ef9b7f24369086ce5f0e9f38d37bc (patch) | |
tree | 44da712b66d778c2fd701f9c96b00e108530e1a9 /kernel/posix-cpu-timers.c | |
parent | 3f4724ea85b7d9055a9976fa8f30b471bdfbca93 (diff) |
cputime: Use accessors to read task cputime stats
This is in preparation for the full dynticks feature. While
remotely reading the cputime of a task running in a full
dynticks CPU, we'll need to do some extra-computation. This
way we can account the time it spent tickless in userspace
since its last cputime snapshot.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Li Zhong <zhong@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/posix-cpu-timers.c')
-rw-r--r-- | kernel/posix-cpu-timers.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index a278cad1d5d6..165d47698477 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -155,11 +155,19 @@ static void bump_cpu_timer(struct k_itimer *timer, | |||
155 | 155 | ||
156 | static inline cputime_t prof_ticks(struct task_struct *p) | 156 | static inline cputime_t prof_ticks(struct task_struct *p) |
157 | { | 157 | { |
158 | return p->utime + p->stime; | 158 | cputime_t utime, stime; |
159 | |||
160 | task_cputime(p, &utime, &stime); | ||
161 | |||
162 | return utime + stime; | ||
159 | } | 163 | } |
160 | static inline cputime_t virt_ticks(struct task_struct *p) | 164 | static inline cputime_t virt_ticks(struct task_struct *p) |
161 | { | 165 | { |
162 | return p->utime; | 166 | cputime_t utime; |
167 | |||
168 | task_cputime(p, &utime, NULL); | ||
169 | |||
170 | return utime; | ||
163 | } | 171 | } |
164 | 172 | ||
165 | static int | 173 | static int |
@@ -471,18 +479,23 @@ static void cleanup_timers(struct list_head *head, | |||
471 | */ | 479 | */ |
472 | void posix_cpu_timers_exit(struct task_struct *tsk) | 480 | void posix_cpu_timers_exit(struct task_struct *tsk) |
473 | { | 481 | { |
482 | cputime_t utime, stime; | ||
483 | |||
474 | add_device_randomness((const void*) &tsk->se.sum_exec_runtime, | 484 | add_device_randomness((const void*) &tsk->se.sum_exec_runtime, |
475 | sizeof(unsigned long long)); | 485 | sizeof(unsigned long long)); |
486 | task_cputime(tsk, &utime, &stime); | ||
476 | cleanup_timers(tsk->cpu_timers, | 487 | cleanup_timers(tsk->cpu_timers, |
477 | tsk->utime, tsk->stime, tsk->se.sum_exec_runtime); | 488 | utime, stime, tsk->se.sum_exec_runtime); |
478 | 489 | ||
479 | } | 490 | } |
480 | void posix_cpu_timers_exit_group(struct task_struct *tsk) | 491 | void posix_cpu_timers_exit_group(struct task_struct *tsk) |
481 | { | 492 | { |
482 | struct signal_struct *const sig = tsk->signal; | 493 | struct signal_struct *const sig = tsk->signal; |
494 | cputime_t utime, stime; | ||
483 | 495 | ||
496 | task_cputime(tsk, &utime, &stime); | ||
484 | cleanup_timers(tsk->signal->cpu_timers, | 497 | cleanup_timers(tsk->signal->cpu_timers, |
485 | tsk->utime + sig->utime, tsk->stime + sig->stime, | 498 | utime + sig->utime, stime + sig->stime, |
486 | tsk->se.sum_exec_runtime + sig->sum_sched_runtime); | 499 | tsk->se.sum_exec_runtime + sig->sum_sched_runtime); |
487 | } | 500 | } |
488 | 501 | ||
@@ -1226,11 +1239,14 @@ static inline int task_cputime_expired(const struct task_cputime *sample, | |||
1226 | static inline int fastpath_timer_check(struct task_struct *tsk) | 1239 | static inline int fastpath_timer_check(struct task_struct *tsk) |
1227 | { | 1240 | { |
1228 | struct signal_struct *sig; | 1241 | struct signal_struct *sig; |
1242 | cputime_t utime, stime; | ||
1243 | |||
1244 | task_cputime(tsk, &utime, &stime); | ||
1229 | 1245 | ||
1230 | if (!task_cputime_zero(&tsk->cputime_expires)) { | 1246 | if (!task_cputime_zero(&tsk->cputime_expires)) { |
1231 | struct task_cputime task_sample = { | 1247 | struct task_cputime task_sample = { |
1232 | .utime = tsk->utime, | 1248 | .utime = utime, |
1233 | .stime = tsk->stime, | 1249 | .stime = stime, |
1234 | .sum_exec_runtime = tsk->se.sum_exec_runtime | 1250 | .sum_exec_runtime = tsk->se.sum_exec_runtime |
1235 | }; | 1251 | }; |
1236 | 1252 | ||