Messages in this thread Patch in this message | | | From | Frederic Weisbecker <> | Subject | [PATCH 1/5] sched: Convert thread_group_cputime() to use for_each_thread() | Date | Wed, 9 Apr 2014 18:11:18 +0200 |
| |
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 <akpm@linux-foundation.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Frederic Weisbecker <fweisbec@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
| |