Installing perf on linux 4 tegra for Jetson AGX

I want to use the perf profiling tool on the Jetson AGX. I am using l4t version 4.9.140-tegra and tried following some of the other forums for Jetson TX2 but none of those seemed to work. Also if I just apt-install linux-tools and use the perf that comes with that it says the following:

WARNING: perf not found for kernel 4.9.140

  You may need to install the following packages for this specific kernel:
    linux-tools-4.9.140-tegra
    linux-cloud-tools-4.9.140-tegra

And of course linux-tools-4.9.140-tegra doesn’t exist as a package.

You may try this. Obviously you would adapt for your kernel version.

When I tried that I get the following error:

BUILD:   Doing 'make -j4' parallel build
Makefile.perf:6: ../scripts/utilities.mak: No such file or directory
make[1]: *** No rule to make target '../scripts/utilities.mak'.  Stop.
Makefile:68: recipe for target 'all' failed
make: *** [all] Error 2

Also I had to use this path: /usr/src/linux-headers-4.9.140-tegra-linux_x86_64/kernel-4.9/tools/perf

The path looks wrong…you are using x86 kernel source. It should be tegra version. This was supposed to be done on Jetson, not on host. On Jetson, it’s unexpected that you have the x86 kernel headers.

I get the same exact error when I use this path: /usr/src/linux-headers-4.9.140-tegra-ubuntu18.04_aarch64/kernel-4.9/tools/perf

Any update on this? This is time critical for a project I am working on.

I have quickly tried on my Xavier R32.2.1 and seen the same. It seems building from headers is not the correct way, it is rather supposed to be built from kernel source instead. That also failed as far I have been able to try, but haven’t had time to investigate this further. You may try on your side and let us know.

Ok thanks for the help.