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?

Will
  • 371
  • 3
  • 16
Frank Meerkötter
  • 219
  • 1
  • 2
  • 4

5 Answers5

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.

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" "$@"
keyhad
  • 11
  • 1
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."

mhansen
  • 111
  • 2
1

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

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
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