Skip to content

Commit 2565e42

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
perf/core: Fix pmus_lock vs. pmus_srcu ordering
Commit a63fbed ("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: a63fbed ("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
1 parent df87d84 commit 2565e42

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/events/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11939,6 +11939,8 @@ void perf_pmu_unregister(struct pmu *pmu)
1193911939
{
1194011940
mutex_lock(&pmus_lock);
1194111941
list_del_rcu(&pmu->entry);
11942+
idr_remove(&pmu_idr, pmu->type);
11943+
mutex_unlock(&pmus_lock);
1194211944

1194311945
/*
1194411946
* We dereference the pmu list under both SRCU and regular RCU, so
@@ -11948,15 +11950,13 @@ void perf_pmu_unregister(struct pmu *pmu)
1194811950
synchronize_rcu();
1194911951

1195011952
free_percpu(pmu->pmu_disable_count);
11951-
idr_remove(&pmu_idr, pmu->type);
1195211953
if (pmu_bus_running && pmu->dev && pmu->dev != PMU_NULL_DEV) {
1195311954
if (pmu->nr_addr_filters)
1195411955
device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
1195511956
device_del(pmu->dev);
1195611957
put_device(pmu->dev);
1195711958
}
1195811959
free_pmu_context(pmu);
11959-
mutex_unlock(&pmus_lock);
1196011960
}
1196111961
EXPORT_SYMBOL_GPL(perf_pmu_unregister);
1196211962

0 commit comments

Comments
 (0)