8

I'd like to use the perf tool on my 2016-02-09 Raspbian Jessie operating system. For that, I have installed the linux-tools package (which contains perf). The kernel version in use on that image is 4.1.17+.

The Linux kernel and it's tools need to have the same version:

root@raspberrypi:/home/pi# perf
/usr/bin/perf: line 24: exec: perf_4.1: not found
E: linux-tools-4.1 is not installed.

Unfortunately there is no 4.1 version for the linux-tools:

root@raspberrypi:/home/pi# aptitude search linux-tools
i   linux-tools                     - Performance analysis tools for Linux (meta
p   linux-tools-3.10                - Performance analysis tools for Linux 3.10 
p   linux-tools-3.12                - Performance analysis tools for Linux 3.12 
i A linux-tools-3.16                - Performance analysis tools for Linux 3.16 
p   linux-tools-3.18                - Performance analysis tools for Linux 3.18 
p   linux-tools-3.6                 - Performance analysis tools for Linux 3.6

Does anyone know how this is supposed to work?

2
  • See this thread: raspberrypi.org/forums/viewtopic.php?f=29&t=117547 It looks that there's no package for the new kernel yet, but in the thread you can find a link for the perf utility built by one of the users.
    – nsilent22
    Commented Feb 28, 2016 at 18:48
  • Dropbox link is now dead, and any guides I can find online don't seem to work for actually compiling perf. Commented Nov 15, 2017 at 9:31

5 Answers 5

4

I was able to install the perf package using sudo apt-get install linux-perf-4.9. Use uname-r to find your kernel version, and apt-cache search linux-tools to find the proper package name.

2
  • 3
    That's cool, but there is no perf package built for the current kernel. Commented Nov 15, 2018 at 19:45
  • @MatthiasUrlichs: maybe try to update it to the latest kernel via sudo rpi-update.
    – jojeck
    Commented Feb 26, 2019 at 16:55
1

I couldn't find good answer, this works for me and now

#sudo nano /usr/bin/perf

then change

#exec "perf_$version" "$@"
exec "perf_4.9" "$@"
1
  • 3
    There is a reason why perf enforces the version check, so one must understand the implications of faking the version number. For one, don't forget to mention this when asking about such problems as nobody will be able to reproduce them otherwise. Commented Sep 26, 2019 at 13:11
1

There's a potential workaround listed at https://github.com/RPi-Distro/repo/issues/159:

"the package found at https://packages.debian.org/buster/armhf/linux-perf-4.19/download seems like it might work."

2
  • The Debian package appeared to work for me on a Pi 3 but it does not work on a Pi Zero.
    – Chad Clark
    Commented Jul 8, 2020 at 17:19
  • 1
    Pi Zero is not armhf architecture, try Debian armel architecture instead. wiki.debian.org/RaspberryPi
    – mhansen
    Commented Jul 15, 2020 at 11:55
1

If perf coming with Raspbian is outdated, there's always the option to install a newer version from Debian repo.

0

I believe you have to recompile it from source, I succeeded recently using the following procedure, kindly provided by https://gibsonic.org/systems/2020/03/18/perf_on_edge_device.html

The steps are summarized below, with $> as prompt:
$> uname -r
5.15.84-v8+
only the first two numbers matter -> my Pi4 kernel version is 5.15
$> sudo apt-get -y install flex bison asciidoc xmlto ...
many libs are useful/needed, see below / later for the ... 'other libs' part
Now grab the kernel source code (will require ~ 1.25 Gb of disk space)
$> cd ~ # assumes we want to store the source code in ~/linux
$> git clone --depth=1 --branch rpi-5.15.y https://github.com/raspberrypi/linux
(be sure to replace 5.15 with your actual kernel version if different)
$> cd linux/tools/perf; make
depending on installed libraries, some of the perf features may/will be disabled or the build may even fail, you can iterate by restarting the perf build from scratch e.g. using
$> make clean; make
after installing libs that seem interesting to you given the hints make will emit regarding disabled features in perf due to missing libraries. My list of sudo apt-get -y install ... libs eventually included (maybe duplicates / not the smartest choices)
libdw-dev libnewt-dev binutils-dev libaudit-dev libgtk2.0-dev libssl-dev python-dev systemtap-sdt-dev libiberty-dev libperl-dev liblzma-dev elfutils-devel libpython2-dev libbabeltrace-ctf-dev libnuma-dev libcap-dev libzstd-dev libelf-dev libslang2-dev
Perhaps after some make clean; make retry cycles to enable the desired features, you should obtain a working executable, test it using
$> sudo ./perf list
If successful, do not forget to build the man pages
$> make install-man
Last but not least, link or copy the working executable at the right location with the right name (change the _5.15 suffix if needed to match your kernel version)
$> sudo mv ./perf /usr/bin/perf_5.15

Hope this helps, mine seems perfectly functional, the whole process only takes a few minutes on my R-Pi4 and the clean/make retry cycle is fast. The massive asciidoc and xmlto features are only needed here to build the man pages and can otherwise be omitted if not already installed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.