perf: Couldn't record kernel reference relocation symbol
What is your kernel? Is it from the linux distributive you use or is it compiled by you (how did you install it)?
First part of warning says about /proc/kallsyms - can you show output of the command (started from the same user you used to run perf)
ls -l /proc/kallsyms
cat /proc/kallsyms | head
Second part of the perf
message says about kptr_restrict sysctl setting. Can you do
cat /proc/sys/kernel/kptr_restrict
to check the setting. Basically, to profile the kernel symbols you should either disable kptr_restrict by setting it to zero (as described in https://lwn.net/Articles/420403/ or https://code.google.com/p/dart/wiki/Profiling):
# Run as root user - e.g. after doing "sudo bash"
echo 0 > /proc/sys/kernel/kptr_restrict
or (https://stackoverflow.com/a/20391360/196561)
sudo sh -c " echo 0 > /proc/sys/kernel/kptr_restrict"
or
echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
or you can always run the perf
from root user.
After setting kptr_restrict to zero or when running perf from root you should get no warning about kallsyms and will be able to profile kernel functions.
Update: seems that perf record
always want access to kallsyms/restricted kptrs, even with userspace-only event (-e cycles:u
)
This tutorial worked perfectly for me!
http://lost-and-found-narihiro.blogspot.com/2012/06/how-to-install-perf-kernel-performance.html
Copied from the tutorial:
$ cat /proc/sys/kernel/kptr_restrict
1
$ echo 0 > /proc/sys/kernel/kptr_restrict
$ cat /proc/sys/kernel/kptr_restrict
0