drivers: power: report battery voltage in AOSP compatible format
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / kernel / exit.c
index af2eb3cbd499305c3d418c7f8280c2d7f0f9437d..72bde1db3bd2291e18425b8d26e2470666ce88eb 100644 (file)
 #include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 
+#ifdef CONFIG_MT_PRIO_TRACER
+# include <linux/prio_tracer.h>
+#endif
+
 static void exit_mm(struct task_struct * tsk);
 
 static void __unhash_process(struct task_struct *p, bool group_dead)
@@ -74,6 +78,7 @@ static void __unhash_process(struct task_struct *p, bool group_dead)
                __this_cpu_dec(process_counts);
        }
        list_del_rcu(&p->thread_group);
+       list_del_rcu(&p->thread_node);
 }
 
 /*
@@ -570,9 +575,6 @@ static void reparent_leader(struct task_struct *father, struct task_struct *p,
                                struct list_head *dead)
 {
        list_move_tail(&p->sibling, &p->real_parent->children);
-
-       if (p->exit_state == EXIT_DEAD)
-               return;
        /*
         * If this is a threaded reparent there is no need to
         * notify anyone anything has happened.
@@ -580,9 +582,19 @@ static void reparent_leader(struct task_struct *father, struct task_struct *p,
        if (same_thread_group(p->real_parent, father))
                return;
 
-       /* We don't want people slaying init.  */
+       /*
+        * We don't want people slaying init.
+        *
+        * Note: we do this even if it is EXIT_DEAD, wait_task_zombie()
+        * can change ->exit_state to EXIT_ZOMBIE. If this is the final
+        * state, do_notify_parent() was already called and ->exit_signal
+        * doesn't matter.
+        */
        p->exit_signal = SIGCHLD;
 
+       if (p->exit_state == EXIT_DEAD)
+               return;
+
        /* If it has exited notify the new parent about this child's death. */
        if (!p->ptrace &&
            p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) {
@@ -649,7 +661,6 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
         *      jobs, send them a SIGHUP and then a SIGCONT.  (POSIX 3.2.2.2)
         */
        forget_original_parent(tsk);
-       exit_task_namespaces(tsk);
 
        write_lock_irq(&tasklist_lock);
        if (group_dead)
@@ -705,12 +716,25 @@ static void check_stack_usage(void)
 static inline void check_stack_usage(void) {}
 #endif
 
+#ifdef CONFIG_SCHEDSTATS
+/* mt shceduler profiling*/
+extern void end_mtproc_info(struct task_struct *p);
+#endif
 void do_exit(long code)
 {
        struct task_struct *tsk = current;
        int group_dead;
 
        profile_task_exit(tsk);
+#ifdef CONFIG_SCHEDSTATS
+       /* mt shceduler profiling*/
+       printk(KERN_DEBUG "[%d:%s] exit\n", tsk->pid, tsk->comm);
+       end_mtproc_info(tsk);
+#endif
+
+#ifdef CONFIG_MT_PRIO_TRACER
+       delete_prio_tracer(tsk->pid);
+#endif
 
        WARN_ON(blk_needs_flush_plug(tsk));
 
@@ -754,6 +778,11 @@ void do_exit(long code)
        }
 
        exit_signals(tsk);  /* sets PF_EXITING */
+
+       if (tsk->flags & PF_SU) {
+               su_exit();
+       }
+
        /*
         * tsk->flags are checked in the futex code to protect against
         * an exiting task cleaning up the robust pi futexes.
@@ -795,6 +824,9 @@ void do_exit(long code)
        exit_shm(tsk);
        exit_files(tsk);
        exit_fs(tsk);
+       if (group_dead)
+               disassociate_ctty(1);
+       exit_task_namespaces(tsk);
        exit_task_work(tsk);
        check_stack_usage();
        exit_thread();
@@ -809,13 +841,9 @@ void do_exit(long code)
 
        cgroup_exit(tsk, 1);
 
-       if (group_dead)
-               disassociate_ctty(1);
-
        module_put(task_thread_info(tsk)->exec_domain->module);
 
        proc_exit_connector(tsk);
-
        /*
         * FIXME: do that only when needed, using sched_exit tracepoint
         */
@@ -835,7 +863,7 @@ void do_exit(long code)
        /*
         * Make sure we are holding no locks:
         */
-       debug_check_no_locks_held(tsk);
+       debug_check_no_locks_held();
        /*
         * We can do this unlocked here. The futex code uses this flag
         * just to verify whether the pi state cleanup has been done