Merge branch 'linus' into perfcounters/core-v2
[linux-drm-fsl-dcu.git] / kernel / exit.c
index 6686ed1e4aa3aedd25a613d3ad7282798392f224..7a14a2b504f520e6bd8a2c88961832c874955d12 100644 (file)
@@ -158,6 +158,9 @@ static void delayed_put_task_struct(struct rcu_head *rhp)
 {
        struct task_struct *tsk = container_of(rhp, struct task_struct, rcu);
 
+#ifdef CONFIG_PERF_COUNTERS
+       WARN_ON_ONCE(!list_empty(&tsk->perf_counter_ctx.counter_list));
+#endif
        trace_sched_process_free(tsk);
        put_task_struct(tsk);
 }
@@ -980,10 +983,6 @@ NORET_TYPE void do_exit(long code)
        tsk->mempolicy = NULL;
 #endif
 #ifdef CONFIG_FUTEX
-       /*
-        * This must happen late, after the PID is not
-        * hashed anymore:
-        */
        if (unlikely(!list_empty(&tsk->pi_state_list)))
                exit_pi_state_list(tsk);
        if (unlikely(current->pi_state_cache))
@@ -1250,6 +1249,12 @@ static int wait_task_zombie(struct task_struct *p, int options,
         */
        read_unlock(&tasklist_lock);
 
+       /*
+        * Flush inherited counters to the parent - before the parent
+        * gets woken up by child-exit notifications.
+        */
+       perf_counter_exit_task(p);
+
        retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
        status = (p->signal->flags & SIGNAL_GROUP_EXIT)
                ? p->signal->group_exit_code : p->exit_code;