Skip to contentSkip to conversation

perf_counter: Ammend cleanup in fork() fail

tip:perfcounters/core tip-bot for Peter Zijlstra 1 participant 1 message May 29, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw
Commit-ID:  bbbee90829304d156c12b171c0ac7e6e1aba8b90
Gitweb:     http://git.kernel.org/tip/bbbee90829304d156c12b171c0ac7e6e1aba8b90
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Fri, 29 May 2009 14:25:58 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 29 May 2009 16:21:52 +0200

perf_counter: Ammend cleanup in fork() fail

When fork() fails we cannot use perf_counter_exit_task() since that assumes to operate on current. Write a new helper that cleans up unused/clean contexts.

Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Corey Ashford <[email protected]>
Cc Marcelo Tosatti <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc John Kacur <[email protected]>

LKML-Reference: <new-submission>

---
 include/linux/perf_counter.h |    2 +
 kernel/fork.c                |    2 +-
 kernel/perf_counter.c        |   43 +++++++++++++++++++++++++++++++++++++++--
 3 files changed, 43 insertions(+), 4 deletions(-)
include/linux/perf_counter.h +2 -0
index 717bf3b..519a41b 100644
@@ -579,6 +579,7 @@ extern void perf_counter_task_sched_out(struct task_struct *task,
 extern void perf_counter_task_tick(struct task_struct *task, int cpu);
 extern int perf_counter_init_task(struct task_struct *child);
 extern void perf_counter_exit_task(struct task_struct *child);
+extern void perf_counter_free_task(struct task_struct *task);
 extern void perf_counter_do_pending(void);
 extern void perf_counter_print_debug(void);
 extern void __perf_disable(void);
@@ -644,6 +645,7 @@ static inline void
 perf_counter_task_tick(struct task_struct *task, int cpu)		{ }
 static inline int perf_counter_init_task(struct task_struct *child)	{ return 0; }
 static inline void perf_counter_exit_task(struct task_struct *child)	{ }
+static inline void perf_counter_free_task(struct task_struct *task)	{ }
 static inline void perf_counter_do_pending(void)			{ }
 static inline void perf_counter_print_debug(void)			{ }
 static inline void perf_disable(void)					{ }
kernel/fork.c +1 -1
index c07c333..23bf757 100644
@@ -1298,7 +1298,7 @@ bad_fork_cleanup_semundo:
 bad_fork_cleanup_audit:
 	audit_free(p);
 bad_fork_cleanup_policy:
-	perf_counter_exit_task(p);
+	perf_counter_free_task(p);
 #ifdef CONFIG_NUMA
 	mpol_put(p->mempolicy);
 bad_fork_cleanup_cgroup:
kernel/perf_counter.c +40 -3

61 lines not on this page · raw message