Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

84.10. perf-7.2.11

The kernel's own profiler: sampling, counters, tracepoints and BPF

Version 7.2.11, release 1
Shelf devtools — Debuggers, tracers, profilers, analysers, linters, language servers and developer utilities
Phase 41_system (System), 382 of 1047 in build order
Licence GPL-2.0-only
Homepage https://perf.wiki.kernel.org/
Build time 1.9 SBU
Installed size 25.2 MiB in 336 files
Recipe ports/core/devtools/perf/kpkgbuild

About

perf is the kernel’s own profiler: it samples where the processors spend their time, counts hardware and software events, records tracepoints and runs BPF programs that summarise in the kernel, then reports what it found (perf top, perf record and perf report, perf stat, perf trace). It is not a project of its own but tools/perf inside the kernel source, so the port’s tarball is the linux port’s tarball under another name, and the two carry the same version and hash. testing/preflight.sh fails the tree when they disagree, because a perf built from another kernel’s source does not fail: it reports unknown record types and misses the newer tracepoints.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/devtools.txt:

The kernel profiler. Built from the same tarball as the linux port and pinned to the same version: a perf built from a different kernel's source does not fail, it silently reports unknown record types.

Sources

Dependencies

Depends on: elfutils, zlib, slang, libtraceevent, libbpf, capstone, numactl, zstd, xz, openssl, python3, clang, llvm, flex, bison, asciidoctor, perl.

Required by: no port names it.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install perf'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/devtools/perf.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/devtools/perf
echo 'fd0fc479f983a8c05313f13e9c36330fe6651cf725396748c40d5cd93fa1e6a4  perf-7.2.11.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/perf
SRC=$SRC_ROOT/perf-7.2.11
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf perf-7.2.11.tar.xz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/perf-docs.patch"
export LDFLAGS="$LDFLAGS -Wl,--strip-debug"

perf_make=(
	make -C tools/perf
	prefix=/usr
	WERROR=0
	EXTRA_CFLAGS="$CFLAGS $LDFLAGS"
	LIBBPF_DYNAMIC=1
	BUILD_BPF_SKEL=1
	NO_LIBPFM4=1
	NO_BABELTRACE2=1
	NO_LIBDEBUGINFOD=1
	NO_JVMTI=1
	NO_SDT=1
	NO_LIBLLVM=1
	NO_PERF_READ_VDSO32=1
	NO_PERF_READ_VDSOX32=1
	NO_BACKTRACE=1
	NO_RUST=1
	LIBPERL=1
	PYTHON_SETUPTOOLS_INSTALLED=no
)

"${perf_make[@]}"

"${perf_make[@]}" DESTDIR="$PKG" install-bin
make -C tools/perf/Documentation prefix=/usr DESTDIR="$PKG" \
	USE_ASCIIDOCTOR=1 PERF_VERSION="$version" \
	KBUILD_BUILD_TIMESTAMP="@$SOURCE_DATE_EPOCH" \
	ASCIIDOC_EXTRA="-a compat-mode -I. -rasciidoctor-extensions -a mansource=perf -a manmanual=perf\\ Manual" \
	install-man

rm -f "$PKG"/usr/libexec/perf-core/tests/pe-file.exe*

install -Dm644 "$PKG"/etc/bash_completion.d/perf "$PKG"/usr/share/bash-completion/completions/perf
rm -r "$PKG"/etc/bash_completion.d
rmdir --ignore-fail-on-non-empty "$PKG"/etc

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/perf, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf perf-7.2.11-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/perf, and runs the triggers its paths call for.

Contents

Installed programs: perf, trace.

Installed directories: /usr/include/perf, /usr/libexec/perf-core, /usr/share/doc/perf-tip, /usr/share/licenses/perf.

Short descriptions

perf Performance analysis tools for Linux

Notes