Filter perf_fds() by the builder's target_cpus - #307
Conversation
|
@utpilla, can you share a bit more context on this change? A concern here is that even when we target a set of CPUs, there are some events (e.g. mmap events) that may come from other CPUs not in the target set that we still need. If we don't include them in |
|
@brianrob Quick context on why we filter: before this PR, Your concern is valid though. It points at an inconsistency the filter exposed: sample events honor So, the real question becomes "should a
What semantic would you lean towards? |
|
For me, mmap/comm/fork are handled at the Exporter level, and the Exporter does not support per-CPU fds, etc. (Someone could still wire them up if they choose to). At the PerfSession level, that does not require mmap/comm/fork (that is an Export or Machine reconstruction state thing), it is not a problem. I'm personally fine with PerfSession and perf_fds being per-CPU only and treating the mmap/comm/fork problem as a separate concern that only really materializes if we move Export or other Export-like scenarios to per-CPU that require them (and at that point that scenario owns the solution they want to implement for that). |
Summary
PerfSession::perf_fds()returned a perf fd for every CPU, ignoring the builder'starget_cpus. A session created with a CPU mask (with_target_cpu) would hand back fds for CPUs the caller explicitly excluded. This filters the exposed fds down to the configured CPU set.Motivation
Leader rings are created for every CPU because all-CPU events (kernel records, and
no_cpu_maskevents added viaadd_event) redirect into them.perf_fds()walked those leaders directly, so masked-out CPUs leaked into the returned list. A push-model consumer would then register fds for CPUs it never asked to watch.