提交 087806b1 编写于 作者: O Oleg Nesterov

redefine thread_group_leader() as exit_signal >= 0

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: NOleg Nesterov <oleg@redhat.com>
Reviewed-by: NTejun Heo <tj@kernel.org>
上级 d4f7c511
...@@ -963,6 +963,7 @@ static int de_thread(struct task_struct *tsk) ...@@ -963,6 +963,7 @@ static int de_thread(struct task_struct *tsk)
leader->group_leader = tsk; leader->group_leader = tsk;
tsk->exit_signal = SIGCHLD; tsk->exit_signal = SIGCHLD;
leader->exit_signal = -1;
BUG_ON(leader->exit_state != EXIT_ZOMBIE); BUG_ON(leader->exit_state != EXIT_ZOMBIE);
leader->exit_state = EXIT_DEAD; leader->exit_state = EXIT_DEAD;
......
...@@ -2284,8 +2284,10 @@ static inline int get_nr_threads(struct task_struct *tsk) ...@@ -2284,8 +2284,10 @@ static inline int get_nr_threads(struct task_struct *tsk)
return tsk->signal->nr_threads; return tsk->signal->nr_threads;
} }
/* de_thread depends on thread_group_leader not being a pid based check */ static inline bool thread_group_leader(struct task_struct *p)
#define thread_group_leader(p) (p == p->group_leader) {
return p->exit_signal >= 0;
}
/* Do to the insanities of de_thread it is possible for a process /* 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 * to have the pid of the thread group leader without actually being
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册