Skip to content

Commit

Permalink
perf/core: Avoid removing shared pmu_context on unregister
Browse files Browse the repository at this point in the history
In commit 1fd7e41 ("perf/core: Remove perf_cpu_context::unique_pmu"),
the search for another user of the pmu_cpu_context was removed, and so
we unconditionally free it during perf_pmu_unregister. This leads to
random corruption later and a BUG at mm/percpu.c:689.

v2: Check for shared pmu_contexts under the mutex.

Fixes: 1fd7e41 ("perf/core: Remove perf_cpu_context::unique_pmu")
Signed-off-by: Chris Wilson <[email protected]>
Cc: David Carrillo-Cisneros <[email protected]>
Cc: Peter Zijlstra (Intel) <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: <[email protected]> # v4.11+
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
ickle committed Sep 16, 2019
1 parent 8acacb0 commit daf77e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -10062,7 +10062,8 @@ void perf_pmu_unregister(struct pmu *pmu)
device_del(pmu->dev);
put_device(pmu->dev);
}
free_pmu_context(pmu);
if (!find_pmu_context(pmu->task_ctx_nr))
free_pmu_context(pmu);
mutex_unlock(&pmus_lock);
}
EXPORT_SYMBOL_GPL(perf_pmu_unregister);
Expand Down

0 comments on commit daf77e4

Please sign in to comment.