Merge git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-drm-fsl-dcu.git] / kernel / exit.c
index 122fadb972fc2dd9ff3fda5cf15c3c0432a50007..bc71fdfcd8a78d4a6b0f466b11f55cb8354bacdd 100644 (file)
@@ -257,8 +257,7 @@ static int has_stopped_jobs(int pgrp)
 }
 
 /**
- * reparent_to_init - Reparent the calling kernel thread to the init task
- * of the pid space that the thread belongs to.
+ * reparent_to_init - Reparent the calling kernel thread to the init task of the pid space that the thread belongs to.
  *
  * If a kernel thread is launched as a result of a system call, or if
  * it ever exits, it should generally reparent itself to init so that
@@ -468,7 +467,7 @@ void fastcall put_files_struct(struct files_struct *files)
                fdt = files_fdtable(files);
                if (fdt != &files->fdtab)
                        kmem_cache_free(files_cachep, files);
-               call_rcu(&fdt->rcu, free_fdtable_rcu);
+               free_fdtable(fdt);
        }
 }
 
@@ -597,10 +596,6 @@ choose_new_parent(struct task_struct *p, struct task_struct *reaper)
 static void
 reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
 {
-       /* We don't want people slaying init.  */
-       if (p->exit_signal != -1)
-               p->exit_signal = SIGCHLD;
-
        if (p->pdeath_signal)
                /* We already hold the tasklist_lock here.  */
                group_send_sig_info(p->pdeath_signal, SEND_SIG_NOINFO, p);
@@ -620,13 +615,7 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
                p->parent = p->real_parent;
                add_parent(p);
 
-               /* If we'd notified the old parent about this child's death,
-                * also notify the new parent.
-                */
-               if (p->exit_state == EXIT_ZOMBIE && p->exit_signal != -1 &&
-                   thread_group_empty(p))
-                       do_notify_parent(p, p->exit_signal);
-               else if (p->state == TASK_TRACED) {
+               if (p->state == TASK_TRACED) {
                        /*
                         * If it was at a trace stop, turn it into
                         * a normal stop since it's no longer being
@@ -636,6 +625,23 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
                }
        }
 
+       /* If this is a threaded reparent there is no need to
+        * notify anyone anything has happened.
+        */
+       if (p->real_parent->group_leader == father->group_leader)
+               return;
+
+       /* We don't want people slaying init.  */
+       if (p->exit_signal != -1)
+               p->exit_signal = SIGCHLD;
+
+       /* If we'd notified the old parent about this child's death,
+        * also notify the new parent.
+        */
+       if (!traced && p->exit_state == EXIT_ZOMBIE &&
+           p->exit_signal != -1 && thread_group_empty(p))
+               do_notify_parent(p, p->exit_signal);
+
        /*
         * process group orphan check
         * Case ii: Our child is in a different pgrp
@@ -931,8 +937,8 @@ fastcall NORET_TYPE void do_exit(long code)
 
        tsk->exit_code = code;
        proc_exit_connector(tsk);
-       exit_notify(tsk);
        exit_task_namespaces(tsk);
+       exit_notify(tsk);
 #ifdef CONFIG_NUMA
        mpol_free(tsk->mempolicy);
        tsk->mempolicy = NULL;