Re: [PATCH 02/10] perf, trace: Use per-tracepoint-per-cpu hlist to track events

Peter Zijlstra
2010-05-21T14:25:19Z

On Fri, 2010-05-21 at 16:18 +0200, Peter Zijlstra wrote:
>
> > That tp_event->perf_refcount is global to the event not to the perf
> > event.
>
> Oh, bugger, yes. I seem to have lost it on destroy..

---
Subject: perf, trace: Fix perf_trace_destroy(), mutex went missing
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Fri May 21 16:22:33 CEST 2010

Steve spotted I forgot to do the destroy under event_mutex.

Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
---
kernel/trace/trace_event_perf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux-2.6/kernel/trace/trace_event_perf.c
===================================================================
--- linux-2.6.orig/kernel/trace/trace_event_perf.c
+++ linux-2.6/kernel/trace/trace_event_perf.c
@@ -125,8 +125,9 @@ void perf_trace_destroy(struct perf_even
struct ftrace_event_call *tp_event = p_event->tp_event;
int i;

+ mutex_lock(&event_mutex);
if (--tp_event->perf_refcount > 0)
- return;
+ goto out;

tp_event->perf_event_disable(tp_event);

@@ -145,6 +146,8 @@ void perf_trace_destroy(struct perf_even
perf_trace_buf[i] = NULL;
}
}
+out:
+ mutex_unlock(&event_mutex);
}

__kprobes void *perf_trace_buf_prepare(int size, unsigned short type,