diff options
-rw-r--r-- | kernel/perf_event.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 49d8be5a45e3..34659d4085c7 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -1867,7 +1867,19 @@ int perf_event_release_kernel(struct perf_event *event) | |||
1867 | event->state = PERF_EVENT_STATE_FREE; | 1867 | event->state = PERF_EVENT_STATE_FREE; |
1868 | 1868 | ||
1869 | WARN_ON_ONCE(ctx->parent_ctx); | 1869 | WARN_ON_ONCE(ctx->parent_ctx); |
1870 | mutex_lock(&ctx->mutex); | 1870 | /* |
1871 | * There are two ways this annotation is useful: | ||
1872 | * | ||
1873 | * 1) there is a lock recursion from perf_event_exit_task | ||
1874 | * see the comment there. | ||
1875 | * | ||
1876 | * 2) there is a lock-inversion with mmap_sem through | ||
1877 | * perf_event_read_group(), which takes faults while | ||
1878 | * holding ctx->mutex, however this is called after | ||
1879 | * the last filedesc died, so there is no possibility | ||
1880 | * to trigger the AB-BA case. | ||
1881 | */ | ||
1882 | mutex_lock_nested(&ctx->mutex, SINGLE_DEPTH_NESTING); | ||
1871 | perf_event_remove_from_context(event); | 1883 | perf_event_remove_from_context(event); |
1872 | mutex_unlock(&ctx->mutex); | 1884 | mutex_unlock(&ctx->mutex); |
1873 | 1885 | ||
@@ -5305,7 +5317,7 @@ void perf_event_exit_task(struct task_struct *child) | |||
5305 | * | 5317 | * |
5306 | * But since its the parent context it won't be the same instance. | 5318 | * But since its the parent context it won't be the same instance. |
5307 | */ | 5319 | */ |
5308 | mutex_lock_nested(&child_ctx->mutex, SINGLE_DEPTH_NESTING); | 5320 | mutex_lock(&child_ctx->mutex); |
5309 | 5321 | ||
5310 | again: | 5322 | again: |
5311 | list_for_each_entry_safe(child_event, tmp, &child_ctx->pinned_groups, | 5323 | list_for_each_entry_safe(child_event, tmp, &child_ctx->pinned_groups, |