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
56cddf71cc
commit
1688acf477
@@ -11846,6 +11846,8 @@ void perf_pmu_unregister(struct pmu *pmu)
|
|||||||
{
|
{
|
||||||
mutex_lock(&pmus_lock);
|
mutex_lock(&pmus_lock);
|
||||||
list_del_rcu(&pmu->entry);
|
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
|
* We dereference the pmu list under both SRCU and regular RCU, so
|
||||||
@@ -11855,7 +11857,6 @@ void perf_pmu_unregister(struct pmu *pmu)
|
|||||||
synchronize_rcu();
|
synchronize_rcu();
|
||||||
|
|
||||||
free_percpu(pmu->pmu_disable_count);
|
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_bus_running && pmu->dev && pmu->dev != PMU_NULL_DEV) {
|
||||||
if (pmu->nr_addr_filters)
|
if (pmu->nr_addr_filters)
|
||||||
device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
|
device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
|
||||||
@@ -11863,7 +11864,6 @@ void perf_pmu_unregister(struct pmu *pmu)
|
|||||||
put_device(pmu->dev);
|
put_device(pmu->dev);
|
||||||
}
|
}
|
||||||
free_pmu_context(pmu);
|
free_pmu_context(pmu);
|
||||||
mutex_unlock(&pmus_lock);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(perf_pmu_unregister);
|
EXPORT_SYMBOL_GPL(perf_pmu_unregister);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user