Hi Suzuki
On 21/10/2024 14:31, Suzuki K Poulose wrote:
Hi Julien
[...]
Unfortunately this is not safe. i.e., event->owner is not guaranteed to be stable (even NULL or an invalid pointer) (e.g. kernel created events or task exit raced event_start on another CPU).
I expected that event->owner was safe, but you are right. During my tests, I essentially attached an existing PID executed in an container (lxc), so I was not able to detect that race condition. I miss to re-validate all the other usage of CoreSight.
That said, one thing to note is that the ETM4x driver parses the event config in each "event_start" call back, instead of doing once during the event_init. If we move this to a onetime parsing at the event_init, with additional checks in place (e.g, !is_kernel_event()), we may be able to solve it.
Thanks for this suggestion, I will try this approach and provide a v3.
Regards, Julien