diff options
author | Oleg Nesterov <oleg@redhat.com> | 2008-11-17 09:40:01 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-17 10:55:54 -0500 |
commit | ce394471d13bf071939a9a0b48c64c297676d233 (patch) | |
tree | ee67e3b6290218b6ecaebd09c1898cde2f3bd95a /kernel/posix-cpu-timers.c | |
parent | 74fcd524e808975dd546dac847119f1995a7c622 (diff) |
thread_group_cputime: kill the bogus ->signal != NULL check
Impact: simplify the code
thread_group_cputime() is called by current when it must have the valid
->signal, or under ->siglock, or under tasklist_lock after the ->signal
check, or the caller is wait_task_zombie() which reaps the child. In any
case ->signal can't be NULL.
But the point of this patch is not optimization. If it is possible to call
thread_group_cputime() when ->signal == NULL we are doing something wrong,
and we should not mask the problem. thread_group_cputime() fills *times
and the caller will use it, if we silently use task_struct->*times* we
report the wrong values.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/posix-cpu-timers.c')
-rw-r--r-- | kernel/posix-cpu-timers.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index 895337b16a24..3f4377e0aa04 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -58,21 +58,21 @@ void thread_group_cputime( | |||
58 | struct task_struct *tsk, | 58 | struct task_struct *tsk, |
59 | struct task_cputime *times) | 59 | struct task_cputime *times) |
60 | { | 60 | { |
61 | struct signal_struct *sig; | 61 | struct task_cputime *totals, *tot; |
62 | int i; | 62 | int i; |
63 | struct task_cputime *tot; | ||
64 | 63 | ||
65 | sig = tsk->signal; | 64 | totals = tsk->signal->cputime.totals; |
66 | if (unlikely(!sig) || !sig->cputime.totals) { | 65 | if (!totals) { |
67 | times->utime = tsk->utime; | 66 | times->utime = tsk->utime; |
68 | times->stime = tsk->stime; | 67 | times->stime = tsk->stime; |
69 | times->sum_exec_runtime = tsk->se.sum_exec_runtime; | 68 | times->sum_exec_runtime = tsk->se.sum_exec_runtime; |
70 | return; | 69 | return; |
71 | } | 70 | } |
71 | |||
72 | times->stime = times->utime = cputime_zero; | 72 | times->stime = times->utime = cputime_zero; |
73 | times->sum_exec_runtime = 0; | 73 | times->sum_exec_runtime = 0; |
74 | for_each_possible_cpu(i) { | 74 | for_each_possible_cpu(i) { |
75 | tot = per_cpu_ptr(tsk->signal->cputime.totals, i); | 75 | tot = per_cpu_ptr(totals, i); |
76 | times->utime = cputime_add(times->utime, tot->utime); | 76 | times->utime = cputime_add(times->utime, tot->utime); |
77 | times->stime = cputime_add(times->stime, tot->stime); | 77 | times->stime = cputime_add(times->stime, tot->stime); |
78 | times->sum_exec_runtime += tot->sum_exec_runtime; | 78 | times->sum_exec_runtime += tot->sum_exec_runtime; |