aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2012-11-21 09:55:59 -0500
committerFrederic Weisbecker <fweisbec@gmail.com>2012-11-28 11:07:38 -0500
commita634f93335daa8f38180a0e576ccd68a73c36eaf (patch)
tree19cb10ec27da81bd07a3eec1b4d4e9f814402c3a /kernel/sched
parentec05a2311c35243cea08bca00bcf53a576ee41a2 (diff)
cputime: Move thread_group_cputime() to sched code
thread_group_cputime() is a general cputime API that is not only used by posix cpu timer. Let's move this helper to sched code. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'kernel/sched')
-rw-r--r--kernel/sched/cputime.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 8d859dae5bed..e56f138a23c7 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -288,6 +288,34 @@ static __always_inline bool steal_account_process_tick(void)
288 return false; 288 return false;
289} 289}
290 290
291/*
292 * Accumulate raw cputime values of dead tasks (sig->[us]time) and live
293 * tasks (sum on group iteration) belonging to @tsk's group.
294 */
295void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
296{
297 struct signal_struct *sig = tsk->signal;
298 struct task_struct *t;
299
300 times->utime = sig->utime;
301 times->stime = sig->stime;
302 times->sum_exec_runtime = sig->sum_sched_runtime;
303
304 rcu_read_lock();
305 /* make sure we can trust tsk->thread_group list */
306 if (!likely(pid_alive(tsk)))
307 goto out;
308
309 t = tsk;
310 do {
311 times->utime += t->utime;
312 times->stime += t->stime;
313 times->sum_exec_runtime += task_sched_runtime(t);
314 } while_each_thread(tsk, t);
315out:
316 rcu_read_unlock();
317}
318
291#ifndef CONFIG_VIRT_CPU_ACCOUNTING 319#ifndef CONFIG_VIRT_CPU_ACCOUNTING
292 320
293#ifdef CONFIG_IRQ_TIME_ACCOUNTING 321#ifdef CONFIG_IRQ_TIME_ACCOUNTING