Re: [PATCH RFC 1/5] perf: Add ioctl to emit sideband events
From: Adrian Hunter
Date: Tue Apr 18 2023 - 02:30:12 EST
On 17/04/23 13:57, Peter Zijlstra wrote:
> On Fri, Apr 14, 2023 at 11:22:56AM +0300, Adrian Hunter wrote:
>> perf tools currently read /proc to get this information, but that
>> races with changes made by the kernel.
>>
>> Add an ioctl to output status-only sideband events for a currently
>> active event on the current CPU. Using timestamps, these status-only
>> sideband events will be correctly ordered with respect to "real"
>> sideband events.
>>
>> The assumption is a user will:
>> - open and enable a dummy event to track sideband events
>> - call the new ioctl to get sideband information for currently
>> running processes as needed
>> - enable the remaining selected events
>>
>> The initial sideband events to be supported will be: fork, namespaces, comm
>> and mmap.
>>
>> Add a new misc flag PERF_RECORD_MISC_STATUS_ONLY to differentiate "real"
>> sideband events from status-only sideband events.
>>
>> The limitation that the event must be active is significant. The ioctl
>> caller must either:
>> i) For a CPU context, set CPU affinity to the correct CPU.
>> Note, obviously that would not need to be done for system-wide
>> tracing on all CPUs. It would also only need to be done for the
>> period of tracing when the ioctl is to be used.
>> ii) Use an event opened for the current process on all CPUs.
>> Note, if such an additional event is needed, it would also use
>> additional memory from the user's perf_event_mlock_kb /
>> RLIMIT_MEMLOCK limit.
>
> Why would a single per-task event not work? I see nothing in the code
> that would require a per-task-per-cpu setup. Or am I just having trouble
> reading again?
Sorry, "all CPUS" should have been "cpu=-1"