- On newer systems:
sudo apt install linux_perf
- On older systems:
sudo apt install linux-tools-$(uname -r)
dnf install perf
On Ubuntu 'perf-archive' script is not installed by default.
- Get perf-archive.sh from linux sources https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/tools/perf/perf-archive.sh
- Save it as
perf-archive(note no.sh) to$(perf --exec-path)/perf-archive. Typically/usr/libexec/perf-core/perf-archive. - Make it executable
chmod +x /usr/libexec/perf-core/perf-archive
perf record ...
Creates perf.data
perf archive
Additionally creates perf.data.tar.bz2 archive.
Copy perf.data and perf.data.tar.bz2 to machine B
Create ~/.debug directory
mkdir ~/.debug
And unpack the archive there
perf archive --unpack perf.data.tar.bz2
This will unpack all the gatherd binaries to ~/.debug directory.
In case you have several reports from the same machine A you can call unpack on all of the perf archives at once.
In case you have a report from a different machine C unpacking archive from different machines into ~/.debug at the same time could still work. Otherwise cleanup ~/.debug directory before unpacking archive from a different machine.
No you can analyze the report from machine A on machine B.
perf report
In case the binary you analyze is stripped from debug symbols, you won't see symbol names in perf report, only the addresses.
- Get unstripped version of a binary
- Place unstripped version of a binary to the same location on machine B that it was on machine A.
- Now running
perf reportshould show you debug symbols.
- Sometimes cleaning up of
~/.debugis necessary perf archive --unpackcould fail if archive has a long name. Rename toperf.data.tar.bz2before unpacking.
- Report function SELF time (time without children), use Intel assembly syntax:
perf report -M intel --no-children
- See difference between 2 perf reports:
perf diff perf_1.data perf_2.data