aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-12-10 18:54:45 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 20:41:17 -0500
commitf6507f83bccd4a5f7dc7091079bf58128dc56d66 (patch)
treef664fee962fdd4521ec1b64143d8a0f21a32a7e0 /kernel/exit.c
parent7f6def9f9b6ebba42fcdc12cfb3092f2cf44b3fe (diff)
exit: wait: cleanup the ptrace_reparented() checks
Now that EXIT_DEAD is the terminal state we can kill "int traced" variable and check "state == EXIT_DEAD" instead to cleanup the code. In particular, this way it is clear that the check obviously doesn't need tasklist_lock. Also fix the type of "unsigned long state", "long" was always wrong although this doesn't matter because cmpxchg/xchg uses typeof(*ptr). [akpm@linux-foundation.org: don't make me google the C Operator Precedence table] Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Aaron Tomlin <atomlin@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Rik van Riel <riel@redhat.com> Cc: Sterling Alexander <stalexan@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.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 9c9526d87276..20875d6398ae 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -973,8 +973,7 @@ static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p,
973 */ 973 */
974static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p) 974static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
975{ 975{
976 unsigned long state; 976 int state, retval, status;
977 int retval, status, traced;
978 pid_t pid = task_pid_vnr(p); 977 pid_t pid = task_pid_vnr(p);
979 uid_t uid = from_kuid_munged(current_user_ns(), task_uid(p)); 978 uid_t uid = from_kuid_munged(current_user_ns(), task_uid(p));
980 struct siginfo __user *infop; 979 struct siginfo __user *infop;
@@ -999,19 +998,18 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
999 } 998 }
1000 return wait_noreap_copyout(wo, p, pid, uid, why, status); 999 return wait_noreap_copyout(wo, p, pid, uid, why, status);
1001 } 1000 }
1002
1003 traced = ptrace_reparented(p);
1004 /* 1001 /*
1005 * Move the task's state to DEAD/TRACE, only one thread can do this. 1002 * Move the task's state to DEAD/TRACE, only one thread can do this.
1006 */ 1003 */
1007 state = traced && thread_group_leader(p) ? EXIT_TRACE : EXIT_DEAD; 1004 state = (ptrace_reparented(p) && thread_group_leader(p)) ?
1005 EXIT_TRACE : EXIT_DEAD;
1008 if (cmpxchg(&p->exit_state, EXIT_ZOMBIE, state) != EXIT_ZOMBIE) 1006 if (cmpxchg(&p->exit_state, EXIT_ZOMBIE, state) != EXIT_ZOMBIE)
1009 return 0; 1007 return 0;
1008
1010 /* 1009 /*
1011 * It can be ptraced but not reparented, check 1010 * Check thread_group_leader() to exclude the traced sub-threads.
1012 * thread_group_leader() to filter out sub-threads.
1013 */ 1011 */
1014 if (likely(!traced) && thread_group_leader(p)) { 1012 if (state == EXIT_DEAD && thread_group_leader(p)) {
1015 struct signal_struct *psig; 1013 struct signal_struct *psig;
1016 struct signal_struct *sig; 1014 struct signal_struct *sig;
1017 unsigned long maxrss; 1015 unsigned long maxrss;