linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* perf_event_open() ABI compatability
@ 2016-01-04 22:19 Vince Weaver
  2016-01-05  9:09 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Vince Weaver @ 2016-01-04 22:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Stephane Eranian


So I think this might be revisiting an issue that has come up before, but
we're having backward compatability issues with PAPI and libpfm4 and
the perf_event_open() system call.

If a user specifies exclude_guest=1 on an older kernel that doesn't 
support it, we get the awesome EINVAL error return code and it often
takes hours to track down the cause.

Now in theory the ABI is maintained via the "size" field.  So you can
figure out the size of the attr struct by setting an invalid size
and then getting E2BIG with size set to the value the kernel expects.
		
This doesn't help with exclude_guest though, as that's in the giant union
in the middle of the attr, and there's absolutely no mechanism at all
to tell when that has been extended.

Is there any solution to all of this, except having to carry around a big 
table of kernel version numbers for when features were added?

Ideally we would somehow want E2BIG returned plus the size of __reserved_1 
if the value of __reserved_1 is not zero.  I suppose at this point in the 
game it's too late for this to be much help and we're going to have to
work around the problem forever anyway.

Vince

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: perf_event_open() ABI compatability
  2016-01-04 22:19 perf_event_open() ABI compatability Vince Weaver
@ 2016-01-05  9:09 ` Peter Zijlstra
  2016-01-11 10:30   ` Alexander Shishkin
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2016-01-05  9:09 UTC (permalink / raw)
  To: Vince Weaver
  Cc: linux-kernel, Ingo Molnar, Arnaldo Carvalho de Melo,
	Stephane Eranian, alexander.shishkin

On Mon, Jan 04, 2016 at 05:19:13PM -0500, Vince Weaver wrote:
> 
> So I think this might be revisiting an issue that has come up before, but
> we're having backward compatability issues with PAPI and libpfm4 and
> the perf_event_open() system call.
> 
> If a user specifies exclude_guest=1 on an older kernel that doesn't 
> support it, we get the awesome EINVAL error return code and it often
> takes hours to track down the cause.
> 
> Now in theory the ABI is maintained via the "size" field.  So you can
> figure out the size of the attr struct by setting an invalid size
> and then getting E2BIG with size set to the value the kernel expects.
> 		
> This doesn't help with exclude_guest though, as that's in the giant union
> in the middle of the attr, and there's absolutely no mechanism at all
> to tell when that has been extended.
> 
> Is there any solution to all of this, except having to carry around a big 
> table of kernel version numbers for when features were added?

The perf tool does a probe thing where it will, in reverse order of
feature addition remove flags.

The advantage of the dynamic probing is that it will work with franken
kernels that have bits backported; where relying on the kernel version
number is pointless.

But yes, this is all somewhat fugly.

> Ideally we would somehow want E2BIG returned plus the size of __reserved_1 
> if the value of __reserved_1 is not zero.  I suppose at this point in the 
> game it's too late for this to be much help and we're going to have to
> work around the problem forever anyway.

Right :/ So I was hoping some of that extended error reporting stuff
from Alexander Shishkin would help out with this. Not sure where that
stranded -- I think in the attempt to make it too generic or so.

But yes, since that too will only be available in new kernels, old
kernels will still have to cope.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: perf_event_open() ABI compatability
  2016-01-05  9:09 ` Peter Zijlstra
@ 2016-01-11 10:30   ` Alexander Shishkin
  2016-01-11 11:28     ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Shishkin @ 2016-01-11 10:30 UTC (permalink / raw)
  To: Peter Zijlstra, Vince Weaver
  Cc: linux-kernel, Ingo Molnar, Arnaldo Carvalho de Melo, Stephane Eranian

Peter Zijlstra <peterz@infradead.org> writes:

> On Mon, Jan 04, 2016 at 05:19:13PM -0500, Vince Weaver wrote:
>> 
>> So I think this might be revisiting an issue that has come up before, but
>> we're having backward compatability issues with PAPI and libpfm4 and
>> the perf_event_open() system call.
>> 
>> If a user specifies exclude_guest=1 on an older kernel that doesn't 
>> support it, we get the awesome EINVAL error return code and it often
>> takes hours to track down the cause.
>> 
>> Now in theory the ABI is maintained via the "size" field.  So you can
>> figure out the size of the attr struct by setting an invalid size
>> and then getting E2BIG with size set to the value the kernel expects.
>> 		
>> This doesn't help with exclude_guest though, as that's in the giant union
>> in the middle of the attr, and there's absolutely no mechanism at all
>> to tell when that has been extended.
>> 
>> Is there any solution to all of this, except having to carry around a big 
>> table of kernel version numbers for when features were added?
>
> The perf tool does a probe thing where it will, in reverse order of
> feature addition remove flags.
>
> The advantage of the dynamic probing is that it will work with franken
> kernels that have bits backported; where relying on the kernel version
> number is pointless.
>
> But yes, this is all somewhat fugly.
>
>> Ideally we would somehow want E2BIG returned plus the size of __reserved_1 
>> if the value of __reserved_1 is not zero.  I suppose at this point in the 
>> game it's too late for this to be much help and we're going to have to
>> work around the problem forever anyway.
>
> Right :/ So I was hoping some of that extended error reporting stuff
> from Alexander Shishkin would help out with this. Not sure where that
> stranded -- I think in the attempt to make it too generic or so.

Yep. I can respin it back into perf-specific shape, so do we still want
it?

Regards,
--
Alex

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: perf_event_open() ABI compatability
  2016-01-11 10:30   ` Alexander Shishkin
@ 2016-01-11 11:28     ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2016-01-11 11:28 UTC (permalink / raw)
  To: Alexander Shishkin
  Cc: Peter Zijlstra, Vince Weaver, linux-kernel, Ingo Molnar,
	Arnaldo Carvalho de Melo, Stephane Eranian


* Alexander Shishkin <alexander.shishkin@linux.intel.com> wrote:

> >> Ideally we would somehow want E2BIG returned plus the size of __reserved_1 if 
> >> the value of __reserved_1 is not zero.  I suppose at this point in the game 
> >> it's too late for this to be much help and we're going to have to work around 
> >> the problem forever anyway.
> >
> > Right :/ So I was hoping some of that extended error reporting stuff from 
> > Alexander Shishkin would help out with this. Not sure where that stranded -- I 
> > think in the attempt to make it too generic or so.
> 
> Yep. I can respin it back into perf-specific shape, so do we still want it?

Yeah, please do!

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-11 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-04 22:19 perf_event_open() ABI compatability Vince Weaver
2016-01-05  9:09 ` Peter Zijlstra
2016-01-11 10:30   ` Alexander Shishkin
2016-01-11 11:28     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).