Re: [PATCH v2 24/24] perf: Make perf_pmu_unregister() useable

From: Ravi Bangoria
Date: Mon Feb 17 2025 - 03:25:18 EST


Hi Peter,

>> Apparently not, it ends up with:
>>
>> ------------[ cut here ]------------
>> WARNING: CPU: 145 PID: 5459 at kernel/events/core.c:281 event_function+0xd2/0xf0
>> WARNING: CPU: 145 PID: 5459 at kernel/events/core.c:286 event_function+0xd6/0xf0
>
>> remote_function+0x4f/0x70
>> generic_exec_single+0x7f/0x160
>> smp_call_function_single+0x110/0x160
>> event_function_call+0x98/0x1d0
>> _perf_event_disable+0x41/0x70
>> perf_event_for_each_child+0x40/0x90
>> _perf_ioctl+0xac/0xb00
>> perf_ioctl+0x45/0x80
>
> Took me a long while trying to blame this on the 'event->parent =
> NULL;', but AFAICT this is a new, unrelated issue.
>
> What I think happens is this perf_ioctl(DISABLE) vs pmu_detach_events()
> race, where the crux is that perf_ioctl() path does not take
> event2->mutex which allows the following interleave:

This one was only with perf_fuzzer, so pmu_detach_events() code path was
not invoked.

Thanks,
Ravi