Fredric T
Fredric T

Reputation: 35

Linux perf tool run issues

I am using perf tool to bench mark one of my projects. The issue I am facing is that wo get automatihen I run perf tool on my machine, everything works fine. However, I am trying to run perf in automation servers to make it part of my check in process but I am getting the following error from automation servers

WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
check /proc/sys/kernel/kptr_restrict.

Samples in kernel functions may not be resolved if a suitable vmlinux
file is not found in the buildid cache or in the vmlinux path.

Samples in kernel modules won't be resolved at all.
If some relocation was applied (e.g. kexec) symbols may be misresolved
even with a suitable vmlinux or kallsyms file.

Error:

Permission error - are you root?

Consider tweaking /proc/sys/kernel/perf_event_paranoid:

 -1 - Not paranoid at all

  0 - Disallow raw tracepoint access for unpriv

  1 - Disallow cpu events for unpriv

  2 - Disallow kernel profiling for unpriv

fp: Terminated

I tried changing /proc/sys/kernel/perf_event_paranoid to -1 and 0 but still see the same issue. Anybody seen this before? Why would I need to run the command as root? I am able to run it on my machine without sudo.

by the way, the command is like this:

perf record -m 32 -F 99 -p xxxx -a -g --call-graph fp

Upvotes: 1

Views: 3390

Answers (1)

osgx
osgx

Reputation: 94225

You can't use -a (full system profiling) and sample kernel from non-root user: http://man7.org/linux/man-pages/man1/perf-record.1.html

Try running it without -a option and with event limited to userspace events by :u suffix:

perf record -m 32 -F 99 -p $PID -g --call-graph fp -e cycles:u

Or use software event for virtualized platforms without PMU passthrough

perf record -m 32 -F 99 -p $PID -g --call-graph fp -e cpu-clock:u

Upvotes: 1

Related Questions