]> git.ipfire.org Git - thirdparty/linux.git/commit
perf: Make perf_pmu_unregister() useable
authorPeter Zijlstra <peterz@infradead.org>
Fri, 25 Oct 2024 08:21:41 +0000 (10:21 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 8 Apr 2025 18:55:48 +0000 (20:55 +0200)
commitda916e96e2dedcb2d40de77a7def833d315b81a6
treee5dac626e93b753a7a32b56f728e36c76def148a
parent4da0600edae1cf15d12bebacc66d7237e2c33fc6
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.org
include/linux/perf_event.h
kernel/events/core.c