Commit da916e9
Peter Zijlstra
perf: Make perf_pmu_unregister() useable
Previously it was only safe to call perf_pmu_unregister() if there
were no active events of that pmu around -- which was impossible to
guarantee since it races all sorts against perf_init_event().
Rework the whole thing by:
- keeping track of all events for a given pmu
- 'hiding' the pmu from perf_init_event()
- waiting for the appropriate (s)rcu grace periods such that all
prior references to the PMU will be completed
- detaching all still existing events of that pmu (see first point)
and moving them to a new REVOKED state.
- actually freeing the pmu data.
Where notably the new REVOKED state must inhibit all event actions
from reaching code that wants to use event->pmu.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
Link: https://lkml.kernel.org/r/20250307193723.525402029@infradead.org1 parent 4da0600 commit da916e9
2 files changed
+280
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
328 | 331 | | |
329 | 332 | | |
330 | 333 | | |
| |||
622 | 625 | | |
623 | 626 | | |
624 | 627 | | |
625 | | - | |
626 | | - | |
627 | | - | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
628 | 632 | | |
629 | 633 | | |
630 | 634 | | |
| |||
865 | 869 | | |
866 | 870 | | |
867 | 871 | | |
| 872 | + | |
868 | 873 | | |
869 | 874 | | |
870 | 875 | | |
| |||
1155 | 1160 | | |
1156 | 1161 | | |
1157 | 1162 | | |
1158 | | - | |
| 1163 | + | |
1159 | 1164 | | |
1160 | 1165 | | |
1161 | 1166 | | |
| |||
1760 | 1765 | | |
1761 | 1766 | | |
1762 | 1767 | | |
1763 | | - | |
| 1768 | + | |
1764 | 1769 | | |
1765 | 1770 | | |
1766 | 1771 | | |
| |||
0 commit comments