diff options
author | Oleg Nesterov <oleg@redhat.com> | 2010-05-26 17:43:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:46 -0400 |
commit | d40e48e02f3785b9342ee4eb3d7cc9f12981b7f5 (patch) | |
tree | 05f900ae17f4727c0e8b8c2c84d41b1cee7c13b0 /kernel | |
parent | b7b8ff6373d4b910af081f76888395e6df53249d (diff) |
exit: __exit_signal: use thread_group_leader() consistently
Cleanup:
- Add the boolean, group_dead = thread_group_leader(), for clarity.
- Do not test/set sig == NULL to detect the all-dead case, use this
boolean.
- Pass this boolen to __unhash_process() and use it instead of another
thread_group_leader() call which needs ->group_leader.
This can be considered as microoptimization, but hopefully this also
allows us do do other cleanups later.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/exit.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index bbc790646502..3602f468e3a0 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -58,11 +58,11 @@ | |||
58 | 58 | ||
59 | static void exit_mm(struct task_struct * tsk); | 59 | static void exit_mm(struct task_struct * tsk); |
60 | 60 | ||
61 | static void __unhash_process(struct task_struct *p) | 61 | static void __unhash_process(struct task_struct *p, bool group_dead) |
62 | { | 62 | { |
63 | nr_threads--; | 63 | nr_threads--; |
64 | detach_pid(p, PIDTYPE_PID); | 64 | detach_pid(p, PIDTYPE_PID); |
65 | if (thread_group_leader(p)) { | 65 | if (group_dead) { |
66 | detach_pid(p, PIDTYPE_PGID); | 66 | detach_pid(p, PIDTYPE_PGID); |
67 | detach_pid(p, PIDTYPE_SID); | 67 | detach_pid(p, PIDTYPE_SID); |
68 | 68 | ||
@@ -79,6 +79,7 @@ static void __unhash_process(struct task_struct *p) | |||
79 | static void __exit_signal(struct task_struct *tsk) | 79 | static void __exit_signal(struct task_struct *tsk) |
80 | { | 80 | { |
81 | struct signal_struct *sig = tsk->signal; | 81 | struct signal_struct *sig = tsk->signal; |
82 | bool group_dead = thread_group_leader(tsk); | ||
82 | struct sighand_struct *sighand; | 83 | struct sighand_struct *sighand; |
83 | struct tty_struct *uninitialized_var(tty); | 84 | struct tty_struct *uninitialized_var(tty); |
84 | 85 | ||
@@ -92,7 +93,7 @@ static void __exit_signal(struct task_struct *tsk) | |||
92 | atomic_dec(&sig->count); | 93 | atomic_dec(&sig->count); |
93 | 94 | ||
94 | posix_cpu_timers_exit(tsk); | 95 | posix_cpu_timers_exit(tsk); |
95 | if (thread_group_leader(tsk)) { | 96 | if (group_dead) { |
96 | posix_cpu_timers_exit_group(tsk); | 97 | posix_cpu_timers_exit_group(tsk); |
97 | tty = sig->tty; | 98 | tty = sig->tty; |
98 | sig->tty = NULL; | 99 | sig->tty = NULL; |
@@ -127,10 +128,9 @@ static void __exit_signal(struct task_struct *tsk) | |||
127 | sig->oublock += task_io_get_oublock(tsk); | 128 | sig->oublock += task_io_get_oublock(tsk); |
128 | task_io_accounting_add(&sig->ioac, &tsk->ioac); | 129 | task_io_accounting_add(&sig->ioac, &tsk->ioac); |
129 | sig->sum_sched_runtime += tsk->se.sum_exec_runtime; | 130 | sig->sum_sched_runtime += tsk->se.sum_exec_runtime; |
130 | sig = NULL; /* Marker for below. */ | ||
131 | } | 131 | } |
132 | 132 | ||
133 | __unhash_process(tsk); | 133 | __unhash_process(tsk, group_dead); |
134 | 134 | ||
135 | /* | 135 | /* |
136 | * Do this under ->siglock, we can race with another thread | 136 | * Do this under ->siglock, we can race with another thread |
@@ -142,7 +142,7 @@ static void __exit_signal(struct task_struct *tsk) | |||
142 | 142 | ||
143 | __cleanup_sighand(sighand); | 143 | __cleanup_sighand(sighand); |
144 | clear_tsk_thread_flag(tsk,TIF_SIGPENDING); | 144 | clear_tsk_thread_flag(tsk,TIF_SIGPENDING); |
145 | if (sig) { | 145 | if (group_dead) { |
146 | flush_sigqueue(&sig->shared_pending); | 146 | flush_sigqueue(&sig->shared_pending); |
147 | taskstats_tgid_free(sig); | 147 | taskstats_tgid_free(sig); |
148 | tty_kref_put(tty); | 148 | tty_kref_put(tty); |