Commit 43fa87f7 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

perf/core: Fix another perf,trace,cpuhp lock inversion

Lockdep noticed the following 3-way lockup race:

 #0       mutex_lock(&event_mutex)
              tp_event->class->reg() := tracepoint_probe_register
 #1              mutex_lock(&tracepoints_mutex)
 #2                  static_key_enable()

 #2	do_cpu_up()
 #3	    mutex_lock(&pmus_lock)
 #4	    mutex_lock(&ctx->mutex)

 #4	  ctx = perf_event_ctx_lock()
 #0	      mutex_lock(&event_mutex)

Fudge it for now by noting that the tracepoint state does not depend
on the event <-> context relation. Ugly though :/
Signed-off-by: default avatarPeter Zijlstra (Intel) <>
Cc: Linus Torvalds <>
Cc: Peter Zijlstra <>
Cc: Steven Rostedt <>
Cc: Thomas Gleixner <>
Signed-off-by: default avatarIngo Molnar <>
parent 82d94856
...@@ -8525,6 +8525,29 @@ perf_event_set_addr_filter(struct perf_event *event, char *filter_str) ...@@ -8525,6 +8525,29 @@ perf_event_set_addr_filter(struct perf_event *event, char *filter_str)
return ret; return ret;
} }
static int
perf_tracepoint_set_filter(struct perf_event *event, char *filter_str)
struct perf_event_context *ctx = event->ctx;
int ret;
* Beware, here be dragons!!
* the tracepoint muck will deadlock against ctx->mutex, but the tracepoint
* stuff does not actually need it. So temporarily drop ctx->mutex. As per
* perf_event_ctx_lock() we already have a reference on ctx.
* This can result in event getting moved to a different ctx, but that
* does not affect the tracepoint state.
ret = ftrace_profile_set_filter(event, event->attr.config, filter_str);
return ret;
static int perf_event_set_filter(struct perf_event *event, void __user *arg) static int perf_event_set_filter(struct perf_event *event, void __user *arg)
{ {
char *filter_str; char *filter_str;
...@@ -8541,8 +8564,7 @@ static int perf_event_set_filter(struct perf_event *event, void __user *arg) ...@@ -8541,8 +8564,7 @@ static int perf_event_set_filter(struct perf_event *event, void __user *arg)
event->attr.type == PERF_TYPE_TRACEPOINT) event->attr.type == PERF_TYPE_TRACEPOINT)
ret = ftrace_profile_set_filter(event, event->attr.config, ret = perf_tracepoint_set_filter(event, filter_str);
else if (has_addr_filter(event)) else if (has_addr_filter(event))
ret = perf_event_set_addr_filter(event, filter_str); ret = perf_event_set_addr_filter(event, filter_str);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment