Re: perf: regression -- missing /sys/devices/system/cpu/perf_events
From: Ingo Molnar
Date:  Tue May 24 2011 - 17:29:44 EST
* David Ahern <dsahern@xxxxxxxxx> wrote:
> On 05/24/11 14:12, Vince Weaver wrote:
> > On Tue, 24 May 2011, Ingo Molnar wrote:
> >>
> >> So, what is wrong with the method Peter suggested: the presence of the perf 
> >> syscall (it not returning -ENOSYS) is bona fide evidence that perf is 
> >> available.
> > 
> > it's just hard to do that from a shell script.
> 
> What about kallsyms:
> 
> grep sys_perf_event_open /proc/kallsyms
that looks pretty roundabout and expensive - kallsyms can be large.
Nor is there a guarantee that the function will always be called 
sys_perf_event_open() - we already renamed it from sys_perf_counter_open() as 
you yourself mentioned it :-)
Plus the kernel can be built without /proc/kallsyms, and root can chmod off the 
file permissions of /proc/kallsyms for unprivileged user-space as well. So it's 
not a particularly robust check.
I agree with Vince that as far as shell scripts are concerned, checking 
/proc/sys/kernel/perf_event_paranoid would work best - and it works better than 
having to check the perf syscall.
Vince: mind sending a patch that adds a comment to perf_event_paranoid that 
userspace relies on the existence of that file as a feature check? Having such 
reminders in the code works even better than frequent testing ;-)
As far as the actual PAPI library goes i really hope it checks the syscall 
itself: that's much faster and more robust than an 
access("/proc/sys/kernel/perf_event_paranoid") call ...
Thanks,
	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/