summaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2010-05-26 14:43:19 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-27 09:12:46 -0700
commitd40e48e02f3785b9342ee4eb3d7cc9f12981b7f5 (patch)
tree05f900ae17f4727c0e8b8c2c84d41b1cee7c13b0 /kernel/exit.c
parentb7b8ff6373d4b910af081f76888395e6df53249d (diff)
downloadop-kernel-dev-d40e48e02f3785b9342ee4eb3d7cc9f12981b7f5.zip
op-kernel-dev-d40e48e02f3785b9342ee4eb3d7cc9f12981b7f5.tar.gz
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/exit.c')
-rw-r--r--kernel/exit.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index bbc7906..3602f46 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -58,11 +58,11 @@
static void exit_mm(struct task_struct * tsk);
-static void __unhash_process(struct task_struct *p)
+static void __unhash_process(struct task_struct *p, bool group_dead)
{
nr_threads--;
detach_pid(p, PIDTYPE_PID);
- if (thread_group_leader(p)) {
+ if (group_dead) {
detach_pid(p, PIDTYPE_PGID);
detach_pid(p, PIDTYPE_SID);
@@ -79,6 +79,7 @@ static void __unhash_process(struct task_struct *p)
static void __exit_signal(struct task_struct *tsk)
{
struct signal_struct *sig = tsk->signal;
+ bool group_dead = thread_group_leader(tsk);
struct sighand_struct *sighand;
struct tty_struct *uninitialized_var(tty);
@@ -92,7 +93,7 @@ static void __exit_signal(struct task_struct *tsk)
atomic_dec(&sig->count);
posix_cpu_timers_exit(tsk);
- if (thread_group_leader(tsk)) {
+ if (group_dead) {
posix_cpu_timers_exit_group(tsk);
tty = sig->tty;
sig->tty = NULL;
@@ -127,10 +128,9 @@ static void __exit_signal(struct task_struct *tsk)
sig->oublock += task_io_get_oublock(tsk);
task_io_accounting_add(&sig->ioac, &tsk->ioac);
sig->sum_sched_runtime += tsk->se.sum_exec_runtime;
- sig = NULL; /* Marker for below. */
}
- __unhash_process(tsk);
+ __unhash_process(tsk, group_dead);
/*
* Do this under ->siglock, we can race with another thread
@@ -142,7 +142,7 @@ static void __exit_signal(struct task_struct *tsk)
__cleanup_sighand(sighand);
clear_tsk_thread_flag(tsk,TIF_SIGPENDING);
- if (sig) {
+ if (group_dead) {
flush_sigqueue(&sig->shared_pending);
taskstats_tgid_free(sig);
tty_kref_put(tty);
OpenPOWER on IntegriCloud