redefine thread_group_leader() as exit_signal >= 0
authorOleg Nesterov <oleg@redhat.com>
Wed, 22 Jun 2011 21:10:26 +0000 (23:10 +0200)
committerOleg Nesterov <oleg@redhat.com>
Mon, 27 Jun 2011 18:30:10 +0000 (20:30 +0200)
Change de_thread() to set old_leader->exit_signal = -1. This is
good for the consistency, it is no longer the leader and all
sub-threads have exit_signal = -1 set by copy_process(CLONE_THREAD).

And this allows us to micro-optimize thread_group_leader(), it can
simply check exit_signal >= 0. This also makes sense because we
should move ->group_leader from task_struct to signal_struct.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
fs/exec.c
include/linux/sched.h

index 8dca45b0dae8f5a1df3d633b90997af2cbbc4088..c3d517bfdd273c84ad6051a4fa8a8e1b5f173e81 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -963,6 +963,7 @@ static int de_thread(struct task_struct *tsk)
                leader->group_leader = tsk;
 
                tsk->exit_signal = SIGCHLD;
+               leader->exit_signal = -1;
 
                BUG_ON(leader->exit_state != EXIT_ZOMBIE);
                leader->exit_state = EXIT_DEAD;
index 39acee2c8929715b30ad7e97bdb9c4c6c32b7e71..b38ed51d5c648a9d5f458a0ee98f982c4d40125f 100644 (file)
@@ -2284,8 +2284,10 @@ static inline int get_nr_threads(struct task_struct *tsk)
        return tsk->signal->nr_threads;
 }
 
-/* de_thread depends on thread_group_leader not being a pid based check */
-#define thread_group_leader(p) (p == p->group_leader)
+static inline bool thread_group_leader(struct task_struct *p)
+{
+       return p->exit_signal >= 0;
+}
 
 /* Do to the insanities of de_thread it is possible for a process
  * to have the pid of the thread group leader without actually being