I am currently having trouble running linux perf, mostly because /proc/sys/kernel/kptr_restrict is currently set to 1.
/proc/sys/kernel/kptr_restrict
However, if I try to /proc/sys/
/proc/sys/
In your example, echo is running as root, but your shell is running as you.
echo
So please try this command:
sudo sh -c " echo 0 > /proc/sys/kernel/kptr_restrict"