cputime: Move thread_group_cputime() to sched code
authorFrederic Weisbecker <fweisbec@gmail.com>
Wed, 21 Nov 2012 14:55:59 +0000 (15:55 +0100)
committerFrederic Weisbecker <fweisbec@gmail.com>
Wed, 28 Nov 2012 16:07:38 +0000 (17:07 +0100)
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>
kernel/posix-cpu-timers.c
kernel/sched/cputime.c

index 125cb67daa214440868f1bcd332c35a4b4d18df9..d73840271dcee993936b48cc9e7f7d5f66a5c546 100644 (file)
@@ -217,30 +217,6 @@ static int cpu_clock_sample(const clockid_t which_clock, struct task_struct *p,
        return 0;
 }
 
-void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
-{
-       struct signal_struct *sig = tsk->signal;
-       struct task_struct *t;
-
-       times->utime = sig->utime;
-       times->stime = sig->stime;
-       times->sum_exec_runtime = sig->sum_sched_runtime;
-
-       rcu_read_lock();
-       /* make sure we can trust tsk->thread_group list */
-       if (!likely(pid_alive(tsk)))
-               goto out;
-
-       t = tsk;
-       do {
-               times->utime += t->utime;
-               times->stime += t->stime;
-               times->sum_exec_runtime += task_sched_runtime(t);
-       } while_each_thread(tsk, t);
-out:
-       rcu_read_unlock();
-}
-
 static void update_gt_cputime(struct task_cputime *a, struct task_cputime *b)
 {
        if (b->utime > a->utime)
index 8d859dae5bed59cb28a15858c5aa87e3be30f18c..e56f138a23c71cec8dad0c8f3cf288d63a32c481 100644 (file)
@@ -288,6 +288,34 @@ static __always_inline bool steal_account_process_tick(void)
        return false;
 }
 
+/*
+ * Accumulate raw cputime values of dead tasks (sig->[us]time) and live
+ * tasks (sum on group iteration) belonging to @tsk's group.
+ */
+void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
+{
+       struct signal_struct *sig = tsk->signal;
+       struct task_struct *t;
+
+       times->utime = sig->utime;
+       times->stime = sig->stime;
+       times->sum_exec_runtime = sig->sum_sched_runtime;
+
+       rcu_read_lock();
+       /* make sure we can trust tsk->thread_group list */
+       if (!likely(pid_alive(tsk)))
+               goto out;
+
+       t = tsk;
+       do {
+               times->utime += t->utime;
+               times->stime += t->stime;
+               times->sum_exec_runtime += task_sched_runtime(t);
+       } while_each_thread(tsk, t);
+out:
+       rcu_read_unlock();
+}
+
 #ifndef CONFIG_VIRT_CPU_ACCOUNTING
 
 #ifdef CONFIG_IRQ_TIME_ACCOUNTING