perf/core: Fix pmus_lock vs. pmus_srcu ordering
[ Upstream commit 2565e42539b120b81a68a58da961ce5d1e34eac8 ] Commita63fbed776("perf/tracing/cpuhotplug: Fix locking order") placed pmus_lock inside pmus_srcu, this makes perf_pmu_unregister() trip lockdep. Move the locking about such that only pmu_idr and pmus (list) are modified while holding pmus_lock. This avoids doing synchronize_srcu() while holding pmus_lock and all is well again. Fixes:a63fbed776("perf/tracing/cpuhotplug: Fix locking order") Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20241104135517.679556858@infradead.org Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
90d302619e
commit
7c823e4c30
@@ -11660,6 +11660,8 @@ void perf_pmu_unregister(struct pmu *pmu)
|
||||
{
|
||||
mutex_lock(&pmus_lock);
|
||||
list_del_rcu(&pmu->entry);
|
||||
idr_remove(&pmu_idr, pmu->type);
|
||||
mutex_unlock(&pmus_lock);
|
||||
|
||||
/*
|
||||
* We dereference the pmu list under both SRCU and regular RCU, so
|
||||
@@ -11669,7 +11671,6 @@ void perf_pmu_unregister(struct pmu *pmu)
|
||||
synchronize_rcu();
|
||||
|
||||
free_percpu(pmu->pmu_disable_count);
|
||||
idr_remove(&pmu_idr, pmu->type);
|
||||
if (pmu_bus_running && pmu->dev && pmu->dev != PMU_NULL_DEV) {
|
||||
if (pmu->nr_addr_filters)
|
||||
device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
|
||||
@@ -11677,7 +11678,6 @@ void perf_pmu_unregister(struct pmu *pmu)
|
||||
put_device(pmu->dev);
|
||||
}
|
||||
free_pmu_context(pmu);
|
||||
mutex_unlock(&pmus_lock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(perf_pmu_unregister);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user