Live CPU profiling with perf top

See in real time which functions and kernel paths are consuming CPU across the whole system.

LinuxprofilingperfperformancecpuMedium risk
Run sudo perf top to watch the hottest functions live, or sudo perf top -p PID to profile one process; press 'e' to expand a process into its functions.

01Command

Command
$ sudo perf top

02What it does

perf top samples CPU instruction pointers several thousand times a second and shows a live, sorted list of the functions receiving the most samples — kernel code in square brackets, user code with its library. It answers 'what is hot right now' instantly, unlike htop which only shows the process level. For a deeper saved analysis, perf record -g command then perf report adds call graphs.

03Risk

RiskMedium risk
Requirementslinux-tools / perf package; kernel.perf_event_paranoid low enough (sysctl kernel.perf_event_paranoid=1 or run with sudo); debug symbols for readable names.
!Warning: Perf needs access to kernel counters: if you see 'Permission error', lower kernel.perf_event_paranoid (e.g. sudo sysctl kernel.perf_event_paranoid=1) or run with sudo. Without debug symbols, C++/Rust names show as addresses — install the -dbg/-debuginfo packages of the app. High-overhead sampling can itself slow a loaded machine.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • perf-top(1) - profile a system in realtime
    Ubuntu Manpages · community · 2026-09-17
    Evidence: perf top live-profiles the whole system or a single process (-p PID) and displays the hottest functions by CPU samples.
  • Linux perf Examples — Brendan Gregg
    brendangregg.com · technical · 2026-09-17
    Evidence: perf top shows live CPU functions; perf record/report for saved profiles; perf_event_paranoid governs unprivileged access.

Last verified: 2026-09-18 · Category: Developer

06Related solutions