Re: [PATCH] perf/ring_buffer: ensure atomicity and order of updates

From: Peter Zijlstra
Date: Mon May 14 2018 - 11:24:38 EST


On Mon, May 14, 2018 at 04:20:23PM +0100, Mark Rutland wrote:

> > @@ -10499,6 +10523,9 @@ SYSCALL_DEFINE5(perf_event_open,
> > goto err_cred;
> > }
> >
> > + if (in_compat_syscall())
> > + event->event_caps |= PERF_EV_CAP_COMPAT;
> > +
>
> After a native perf_event_open, you could pass the fd (or exec) to
> another task that was compat (or vice-versa), so this wouldn't work in
> that case (crazy as it may be).
>
> I don't have a better suggestion at present, though.

As discussed on IRC, we could trigger off of the buffer size; if the
buffer is <4G the &= UINT_MAX is harmless, if the buffer is larger, you
have to be using a 64bit thingy anyway.

Flipping the overflow functions around on attach/detach to buffers is a
little more dodgy, but could be done I suppose.