Skip to contentSkip to conversation

perf_counter: Annotate exit ctx recursion

tip:perfcounters/core tip-bot for Peter Zijlstra 1 participant 1 message Jun 11, 2009

lore
Share & tools
lore
#0 lore raw
Commit-ID:  66fff22483d8542dfb4d61a28d21277bbde321e8
Gitweb:     http://git.kernel.org/tip/66fff22483d8542dfb4d61a28d21277bbde321e8
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Wed, 10 Jun 2009 22:53:37 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 11 Jun 2009 02:39:01 +0200

perf_counter: Annotate exit ctx recursion

Ever since Paul fixed it to unclone the context before taking the ctx->lock this became a false positive, annotate it away.

Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

LKML-Reference: <new-submission>

---
 kernel/perf_counter.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
kernel/perf_counter.c +12 -1
index 51c571e..ae591a1 100644
@@ -3879,7 +3879,18 @@ void perf_counter_exit_task(struct task_struct *child)
 	spin_unlock(&child_ctx->lock);
 	local_irq_restore(flags);
 
-	mutex_lock(&child_ctx->mutex);
+	/*
+	 * We can recurse on the same lock type through:
+	 *
+	 *   __perf_counter_exit_task()
+	 *     sync_child_counter()
+	 *       fput(parent_counter->filp)
+	 *         perf_release()
+	 *           mutex_lock(&ctx->mutex)
+	 *
+	 * But since its the parent context it won't be the same instance.
+	 */
+	mutex_lock_nested(&child_ctx->mutex, SINGLE_DEPTH_NESTING);
 
 again:
 	list_for_each_entry_safe(child_counter, tmp, &child_ctx->counter_list,