Skip to content

Commit

Permalink
perf_counter: fix threaded task exit
Browse files Browse the repository at this point in the history
Flushing counters in __exit_signal() with irqs disabled is not
a good idea as perf_counter_exit_task() acquires mutexes. So
flush it before acquiring the tasklist lock.

(Note, we still need a fix for when the PID has been unhashed.)

[ Impact: fix crash with inherited counters ]

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Ingo Molnar committed May 17, 2009
1 parent 856d56b commit 0203026
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ static void __exit_signal(struct task_struct *tsk)
sig = NULL; /* Marker for below. */
}

/*
* Flush inherited counters to the parent - before the parent
* gets woken up by child-exit notifications.
*/
perf_counter_exit_task(tsk);

__unhash_process(tsk);

/*
Expand Down Expand Up @@ -183,6 +177,13 @@ void release_task(struct task_struct * p)
atomic_dec(&__task_cred(p)->user->processes);

proc_flush_task(p);

/*
* Flush inherited counters to the parent - before the parent
* gets woken up by child-exit notifications.
*/
perf_counter_exit_task(p);

write_lock_irq(&tasklist_lock);
tracehook_finish_release_task(p);
__exit_signal(p);
Expand Down

0 comments on commit 0203026

Please sign in to comment.