[PATCH 1/1] Return EINVAL when precise_ip perf events are requested on Arm

James Clark James.Clark at arm.com
Fri Jan 17 07:00:37 PST 2020

Hi Peter,

Do you mean something like this?

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 43d1d4945433..f74acd085bea 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10812,6 +10812,12 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
                goto err_pmu;
+       if (event->attr.precise_ip &&
+               !(pmu->capabilities & PERF_PMU_CAP_PRECISE_IP)) {
+               err = -EOPNOTSUPP;
+               goto err_pmu;
+       }
        err = exclusive_event_init(event);
        if (err)
                goto err_pmu;

Or should it only be done via sysfs to not break userspace?

If this was done via sysfs would it be possible to express that some events support
some attributes and others don't? It seems like the "caps" folder couldn't be
that fine grained.

On 17/01/2020 14:01, Peter Zijlstra wrote:
> On Fri, Jan 17, 2020 at 12:39:21PM +0000, Will Deacon wrote:
>> Perhaps a better way would be to expose something under sysfs, a bit like
>> the caps directory for the SPE PMU, which identifies the fields of the attr
>> structure that the driver does not ignore. I think doing this as an Arm-PMU
>> specific thing initially would be fine, but it would be even better to have
>> something where a driver can tell perf core about the parts it responds to
>> and have this stuff populated automatically. The current design makes it
>> inevitable that PMU drivers will have issues like the one you point out in
>> the cover letter.
>> Thoughts?
> We have PERF_PMU_CAP_ flags we could extend to that purpose.

More information about the linux-arm-kernel mailing list