lkml.org 
[lkml]   [2020]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] Return EINVAL when precise_ip perf events are requested on Arm
On Fri, Jan 17, 2020 at 04:16:58PM +0100, Peter Zijlstra wrote:
> On Fri, Jan 17, 2020 at 03:00:37PM +0000, James Clark wrote:
> > Hi Peter,
> >
> > Do you mean something like this?
>
> Yes.
>
> > 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?
>
> So we've added checks like this in the past and gotten away with it. Do
> you already know of some userspace that will break due to it?
>
> An alternative approach is adding a sysctl like kernel.perf_nostrict
> which would disable this or something, that way 'old' userspace has a
> chicken bit.

Could we allocate a "strict" bit from perf_event_attr::__reserved_1, and
update drivers to expose a whitelist of fields they support?

Then the core could do something like:

if (attr->strict && !pmu_check_whitelist(pmu, attr))
return -EOPNOTSUPP;

... and we could also expose the whitelist somewhere in sysfs.

Thanks,
Mark,

\
 
 \ /
  Last update: 2020-01-20 16:35    [W:0.314 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site