]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
exit: wait: cleanup the ptrace_reparented() checks
authorOleg Nesterov <oleg@redhat.com>
Wed, 10 Dec 2014 23:54:45 +0000 (15:54 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Dec 2014 01:41:17 +0000 (17:41 -0800)
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>
kernel/exit.c

index 9c9526d8727663d9c1a4f7802527929f47f185c7..20875d6398ae564d1c62480e5a868e13525022a6 100644 (file)
@@ -973,8 +973,7 @@ static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p,
  */
 static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
 {
-       unsigned long state;
-       int retval, status, traced;
+       int state, retval, status;
        pid_t pid = task_pid_vnr(p);
        uid_t uid = from_kuid_munged(current_user_ns(), task_uid(p));
        struct siginfo __user *infop;
@@ -999,19 +998,18 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
                }
                return wait_noreap_copyout(wo, p, pid, uid, why, status);
        }
-
-       traced = ptrace_reparented(p);
        /*
         * Move the task's state to DEAD/TRACE, only one thread can do this.
         */
-       state = traced && thread_group_leader(p) ? EXIT_TRACE : EXIT_DEAD;
+       state = (ptrace_reparented(p) && thread_group_leader(p)) ?
+               EXIT_TRACE : EXIT_DEAD;
        if (cmpxchg(&p->exit_state, EXIT_ZOMBIE, state) != EXIT_ZOMBIE)
                return 0;
+
        /*
-        * It can be ptraced but not reparented, check
-        * thread_group_leader() to filter out sub-threads.
+        * Check thread_group_leader() to exclude the traced sub-threads.
         */
-       if (likely(!traced) && thread_group_leader(p)) {
+       if (state == EXIT_DEAD && thread_group_leader(p)) {
                struct signal_struct *psig;
                struct signal_struct *sig;
                unsigned long maxrss;