aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2011-01-19 06:51:39 -0500
committerIngo Molnar <mingo@elte.hu>2011-01-21 10:32:42 -0500
commit547e9fd7d328af261f184bf66effc5033c886498 (patch)
tree88c2cbe138029a017769d4465798db181b1c5461 /kernel
parent8c8a9b25b5de3f1eeac721cf34f4379e56d5d694 (diff)
perf: Annotate cpuctx->ctx.mutex to avoid a lockdep splat
Lockdep spotted: loop_1b_instruc/1899 is trying to acquire lock: (event_mutex){+.+.+.}, at: [<ffffffff810e1908>] perf_trace_init+0x3b/0x2f7 but task is already holding lock: (&ctx->mutex){+.+.+.}, at: [<ffffffff810eb45b>] perf_event_init_context+0xc0/0x218 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&ctx->mutex){+.+.+.}: -> #2 (cpu_hotplug.lock){+.+.+.}: -> #1 (module_mutex){+.+...}: -> #0 (event_mutex){+.+.+.}: But because the deadlock would be cpuhotplug (cpu-event) vs fork (task-event) it cannot, in fact, happen. We can annotate this by giving the perf_event_context used for the cpuctx a different lock class from those used by tasks. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/perf_event.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 244ca3acb0ee..c5fa717cf099 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -5380,6 +5380,8 @@ free_dev:
5380 goto out; 5380 goto out;
5381} 5381}
5382 5382
5383static struct lock_class_key cpuctx_mutex;
5384
5383int perf_pmu_register(struct pmu *pmu, char *name, int type) 5385int perf_pmu_register(struct pmu *pmu, char *name, int type)
5384{ 5386{
5385 int cpu, ret; 5387 int cpu, ret;
@@ -5428,6 +5430,7 @@ skip_type:
5428 5430
5429 cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu); 5431 cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
5430 __perf_event_init_context(&cpuctx->ctx); 5432 __perf_event_init_context(&cpuctx->ctx);
5433 lockdep_set_class(&cpuctx->ctx.mutex, &cpuctx_mutex);
5431 cpuctx->ctx.type = cpu_context; 5434 cpuctx->ctx.type = cpu_context;
5432 cpuctx->ctx.pmu = pmu; 5435 cpuctx->ctx.pmu = pmu;
5433 cpuctx->jiffies_interval = 1; 5436 cpuctx->jiffies_interval = 1;