Skip to content

Commit 96f7268

Browse files
ickletursulin
authored andcommitted
perf/core: Avoid removing shared pmu_context on unregister
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 <chris@chris-wilson.co.uk> Cc: David Carrillo-Cisneros <davidcc@google.com> Cc: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: <stable@vger.kernel.org> # v4.11+ Link: http://patchwork.freedesktop.org/patch/msgid/20170512114525.17575-1-chris@chris-wilson.co.uk Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 1cb152f commit 96f7268

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/events/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11342,7 +11342,8 @@ void perf_pmu_unregister(struct pmu *pmu)
1134211342
device_del(pmu->dev);
1134311343
put_device(pmu->dev);
1134411344
}
11345-
free_pmu_context(pmu);
11345+
if (!find_pmu_context(pmu->task_ctx_nr))
11346+
free_pmu_context(pmu);
1134611347
mutex_unlock(&pmus_lock);
1134711348
}
1134811349
EXPORT_SYMBOL_GPL(perf_pmu_unregister);

0 commit comments

Comments
 (0)