On Fri, Sep 18, 2020 at 10:29:01PM +0000, Al Grant wrote:
[...]
Would it be possible to reserve a few flags in the capabilities area of the main mmap buffer, to indicate "flags that tell you about the AUX data"? That would be another way for the kernel to tell userspace what
it's doing.
I think Al suggests to change the data structure perf_event_mmap_page like below:
struct perf_event_mmap_page {
union { __u64 capabilities; struct { __u64 cap_bit0 : 1, /* Always 0, deprecated, see commit
860f085b74e9 */ cap_bit0_is_deprecated : 1, /* Always 1, signals that bit 0 is zero */
cap_user_rdpmc : 1, /* The RDPMC instruction can be used to
read counts */ cap_user_time : 1, /* The time_{shift,mult,offset} fields are used */ cap_user_time_zero : 1, /* The time_zero field is used */ cap_user_time_short : 1, /* the time_{cycle,mask} fields are used */
cap_vhe : 1, /* System supports VHE or not */ cap_____res : 57; }; };
IMHO, I have concern for this since the capability 'cap_vhe' is specific for Arm64 arch and it cannot be commonly applied on other archs.
I was thinking more that the mmap header would have something like
cap_eventflag1:1 cap_eventflag2:1
allocated for event-specific flags. Then those flags can be used for meanings specific to event. The same goes for flags in the perf record headers - if a handful of flags are reserved for event-specific use, their meanings can be different for different event types.
This approach might be difficult to extend, especially if one perf session enabls multiple events (and it's very flexiable for event numbers), so it leads to unlimited event flags.
Another potential issue is how to sent these event flags in the kernel. One way is to use a central place to set these event flags, like in the function arch_perf_update_userpage(), but these means this function needs to know every events ID and their associated event flags; another way is to spread event flag setting in individual PMU drivers, this brings a requirement for program flow: the event flag setting in PMU driver must be prior to reading mmap page in the perf tool.
Thanks Leo