0

I'm running the following command line using perf

$ perf stat ./program
[...]
<not supported> instructions
<not supported> branches
<not supported> branch-misses
<not supported> cycles
[...]
$ cat /proc/sys/kernel/perf_event_paranoid
3

How do I enable these events? Mainly instructions and cycles? I already changed the value to -1 in the /proc/sys/kernel/perf_event_paranoid file, but it keeps the events off, when I reboot, it goes back to the original value which is 3.

Rachid K.
  • 3,136
  • 2
  • 7
  • 24
  • 3
    Are you running on a VM or a bare machine ? – Rachid K. Feb 21 '21 at 07:21
  • 1
    Provide Linux version ("uname -r") and "perf list" output. – Rachid K. Feb 21 '21 at 07:37
  • 2
    Changes to files in `/proc/sys` only affect the current boot. If you want to apply them on the next boot, put the setting in `/etc/sysctl.d/99-local.conf` or a similar file for your distro. (Where boot scripts will apply them.) But if changing it to `-1` didn't work even for the current boot, probably you're running in a VM (which doesn't pass through HW perf counters; very few if any do; I think KVM was/is working on it.) Another possibility is a really ancient CPU, or an exotic one (like Via maybe) that perf doesn't know about. `/proc/cpuinfo` will tell you what you have. – Peter Cordes Feb 21 '21 at 09:28
  • I'm using a VM @RachidK. –  Feb 21 '21 at 15:11
  • Can you tell how I can test how many cycles and instructions a routine written in C takes? –  Feb 21 '21 at 15:14
  • 1
    On a VM, the same question has been raised several times on StackOverflow. For example : https://stackoverflow.com/a/44253130/14393739, https://stackoverflow.com/q/49866115/14393739 – Rachid K. Feb 21 '21 at 15:17
  • Okay, thank you so much for helping me, now I could tell you how I can test a C routine, I want to know how many cycles a routine spends ? @RachidK. –  Feb 21 '21 at 15:22

0 Answers0