do_each_thread/while_each_thread iterators are deprecated by
for_each_thread/for_each_process_thread() APIs.

Lets convert the callers in the cputime code accounting. The ultimate
goal is to remove the struct task_struct::thread_group field and
the corresponding do_each_thread/while_each_thread iterators that are
RCU unsafe.

It also makes thread_group_cputime() eventually RCU-safe.

Cc: Andrew Morton <a...@linux-foundation.org>
Cc: Ingo Molnar <mi...@kernel.org>
Cc: Oleg Nesterov <o...@redhat.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Signed-off-by: Frederic Weisbecker <fweis...@gmail.com>
---
 kernel/sched/cputime.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index a95097c..5d27848 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -281,11 +281,11 @@ static __always_inline bool 
steal_account_process_tick(void)
 
 /*
  * Accumulate raw cputime values of dead tasks (sig->[us]time) and live
- * tasks (sum on group iteration) belonging to @tsk's group.
+ * tasks (sum on group iteration) belonging to @p's group.
  */
-void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
+void thread_group_cputime(struct task_struct *p, struct task_cputime *times)
 {
-       struct signal_struct *sig = tsk->signal;
+       struct signal_struct *sig = p->signal;
        cputime_t utime, stime;
        struct task_struct *t;
 
@@ -295,16 +295,15 @@ void thread_group_cputime(struct task_struct *tsk, struct 
task_cputime *times)
 
        rcu_read_lock();
        /* make sure we can trust tsk->thread_group list */
-       if (!likely(pid_alive(tsk)))
+       if (!likely(pid_alive(p)))
                goto out;
 
-       t = tsk;
-       do {
+       for_each_thread(p, t) {
                task_cputime(t, &utime, &stime);
                times->utime += utime;
                times->stime += stime;
                times->sum_exec_runtime += task_sched_runtime(t);
-       } while_each_thread(tsk, t);
+       }
 out:
        rcu_read_unlock();
 }
-- 
1.8.3.1

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

Reply via email to