]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/exit.c
memcontrol: move oom task exclusion to tasklist scan
[linux-2.6-omap-h63xx.git] / kernel / exit.c
index 549c0558ba68273c7586b26f6579d12c27d0f79d..eb9934a82fc1a900f29eb751e520603b82f2492f 100644 (file)
@@ -50,8 +50,6 @@
 #include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 
-extern void sem_exit (void);
-
 static void exit_mm(struct task_struct * tsk);
 
 static void __unhash_process(struct task_struct *p)
@@ -249,7 +247,7 @@ static int has_stopped_jobs(struct pid *pgrp)
        struct task_struct *p;
 
        do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
-               if (p->state != TASK_STOPPED)
+               if (!task_is_stopped(p))
                        continue;
                retval = 1;
                break;
@@ -614,7 +612,7 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
                p->parent = p->real_parent;
                add_parent(p);
 
-               if (p->state == TASK_TRACED) {
+               if (task_is_traced(p)) {
                        /*
                         * If it was at a trace stop, turn it into
                         * a normal stop since it's no longer being
@@ -1085,11 +1083,12 @@ do_group_exit(int exit_code)
                struct signal_struct *const sig = current->signal;
                struct sighand_struct *const sighand = current->sighand;
                spin_lock_irq(&sighand->siglock);
-               if (sig->flags & SIGNAL_GROUP_EXIT)
+               if (signal_group_exit(sig))
                        /* Another thread got here before we took the lock.  */
                        exit_code = sig->group_exit_code;
                else {
                        sig->group_exit_code = exit_code;
+                       sig->flags = SIGNAL_GROUP_EXIT;
                        zap_other_threads(current);
                }
                spin_unlock_irq(&sighand->siglock);
@@ -1563,60 +1562,49 @@ repeat:
                        }
                        allowed = 1;
 
-                       switch (p->state) {
-                       case TASK_TRACED:
-                               /*
-                                * When we hit the race with PTRACE_ATTACH,
-                                * we will not report this child.  But the
-                                * race means it has not yet been moved to
-                                * our ptrace_children list, so we need to
-                                * set the flag here to avoid a spurious ECHILD
-                                * when the race happens with the only child.
-                                */
-                               flag = 1;
-                               if (!my_ptrace_child(p))
-                                       continue;
-                               /*FALLTHROUGH*/
-                       case TASK_STOPPED:
+                       if (task_is_stopped_or_traced(p)) {
                                /*
                                 * It's stopped now, so it might later
                                 * continue, exit, or stop again.
+                                *
+                                * When we hit the race with PTRACE_ATTACH, we
+                                * will not report this child.  But the race
+                                * means it has not yet been moved to our
+                                * ptrace_children list, so we need to set the
+                                * flag here to avoid a spurious ECHILD when
+                                * the race happens with the only child.
                                 */
                                flag = 1;
-                               if (!(options & WUNTRACED) &&
-                                   !my_ptrace_child(p))
-                                       continue;
+
+                               if (!my_ptrace_child(p)) {
+                                       if (task_is_traced(p))
+                                               continue;
+                                       if (!(options & WUNTRACED))
+                                               continue;
+                               }
+
                                retval = wait_task_stopped(p, ret == 2,
-                                                          (options & WNOWAIT),
-                                                          infop,
-                                                          stat_addr, ru);
+                                               (options & WNOWAIT), infop,
+                                               stat_addr, ru);
                                if (retval == -EAGAIN)
                                        goto repeat;
                                if (retval != 0) /* He released the lock.  */
                                        goto end;
-                               break;
-                       default:
-                       // case EXIT_DEAD:
-                               if (p->exit_state == EXIT_DEAD)
+                       } else if (p->exit_state == EXIT_ZOMBIE) {
+                               /*
+                                * Eligible but we cannot release it yet:
+                                */
+                               if (ret == 2)
+                                       goto check_continued;
+                               if (!likely(options & WEXITED))
                                        continue;
-                       // case EXIT_ZOMBIE:
-                               if (p->exit_state == EXIT_ZOMBIE) {
-                                       /*
-                                        * Eligible but we cannot release
-                                        * it yet:
-                                        */
-                                       if (ret == 2)
-                                               goto check_continued;
-                                       if (!likely(options & WEXITED))
-                                               continue;
-                                       retval = wait_task_zombie(
-                                               p, (options & WNOWAIT),
-                                               infop, stat_addr, ru);
-                                       /* He released the lock.  */
-                                       if (retval != 0)
-                                               goto end;
-                                       break;
-                               }
+                               retval = wait_task_zombie(p,
+                                               (options & WNOWAIT), infop,
+                                               stat_addr, ru);
+                               /* He released the lock.  */
+                               if (retval != 0)
+                                       goto end;
+                       } else if (p->exit_state != EXIT_DEAD) {
 check_continued:
                                /*
                                 * It's running now, so it might later
@@ -1625,12 +1613,11 @@ check_continued:
                                flag = 1;
                                if (!unlikely(options & WCONTINUED))
                                        continue;
-                               retval = wait_task_continued(
-                                       p, (options & WNOWAIT),
-                                       infop, stat_addr, ru);
+                               retval = wait_task_continued(p,
+                                               (options & WNOWAIT), infop,
+                                               stat_addr, ru);
                                if (retval != 0) /* He released the lock.  */
                                        goto end;
-                               break;
                        }
                }
                if (!flag) {