Jump to content

perf (Linux)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 70.36.235.184 (talk) at 04:58, 5 July 2014 (External links). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Written inC
Operating systemLinux kernel
Typeperformance monitor and testing
LicenseGNU GPL
Websiteperf.wiki.kernel.org/index.php/Main_Page

perf (sometimes called "Perf Events"[1] or perf tools, originally "Performance Counters for Linux", PCL[2]) is a performance analyzing tool in Linux, available from Linux kernel version 2.6.31.[3] Userspace controlling utility, named perf, is accessed from the command line and provides a number of subcommands; it is capable of statistical profiling of the entire system (both kernel and userland code).

It supports hardware performance counters, tracepoints, software performance counters (e.g. hrtimer), and dynamic probes (for example, kprobes or uprobes).[4] In 2012, IBM recognized perf (along with OProfile) as one of the two most commonly used performance counter profiling tools on Linux.[5]

With Linux kernel 3.14, released on 31 March 2014, perf also supports running average power limit (RAPL) for power consumption measurements, which is available of Intel CPUs.[6][7][8]

Subcommands

perf is used with several subcommands:

  • stat: measure total event count for single program or for system for some time
  • top: top-like dynamic view of hottest functions
  • record: measure and save sampling data for single program[9]
  • report: analyze file generated by perf record; can generate flat, or graph profile.[9]
  • annotate: annotate sources or assembly
  • sched: tracing/measuring of scheduler actions and latencies[10]
  • list: list available events

Implementation

The interface between a utility and the kernel consists of only one syscall and is done via a file descriptor and a mmaped memory region.[11] Unlike oprofile or LTTng, no service daemons are needed, as most functionality is integrated into the kernel. The perf utility periodically dumps raw data from the mmaped buffer to disk.

According to R. Vitillo (LBNL), perf is a low-overhead profiling tool.[11]

Architectures with hardware counters support at 2010: x86, PowerPC64, UltraSPARC (III and IV), ARM (v5, v6, v7, Cortex-A8 and -A9), Alpha EV56, SH.[4]

Usage of Last Branch Records,[12] a branch tracing implementation in newer Intel CPUs, is available with a patch.[11]

Perf is supported by RHEL6,[13] Debian Squeeze[14] and other popular Linux distributions.

Critics

The documentation of perf is not very detailed (as of 2014); for example, it does not document most events or explain their aliases (often external tools are used to get names and codes of events[15]).[16] Perf tools also cannot profile based on true wall-clock time.[16]

The perf subsystem of Linux kernels from 2.6.37 up to 3.8.8 and RHEL6 kernel 2.6.32 contained a security vulnerability (CVE-2013-2094), which was exploited to gain root privileges by a local user.[17][18] The problem was due to an incorrect type being used (32-bit int instead of 64-bit) in the event_id verification code path.[19]

See also

References

  1. ^ Vince Weaver, The Unofficial Linux Perf Events Web-Page
  2. ^ Linux perf event Features and Overhead // 2013 FastPath Workshop, Vince Weaver
  3. ^ Jake Edge, Perfcounters added to the mainline, LWN July 1, 2009, "perfcounters being included into the mainline during the recently completed 2.6.31 merge window"
  4. ^ a b Arnaldo Carvalho de Melo, The New Linux ’perf’ tools, presentation from Linux Kongress, September, 2010
  5. ^ A. Zanella, R. Arnold. Evaluate performance for Linux on POWER. Analyze performance using Linux tools, 12 Jun 2012 // IBM DeveloperWorks Technical library
  6. ^ Jake Edge (2014-04-09). "Lots of new perf features". LWN.net. Retrieved 2014-04-22.
  7. ^ Jacob Pan (2013-04-02). "RAPL (Running Average Power Limit) driver". LWN.net. Retrieved 2014-04-22.
  8. ^ "kernel/git/torvalds/linux.git - Linux kernel source tree". Git.kernel.org. 2014-01-20. Retrieved 2014-03-31.
  9. ^ a b Urs Fässler perf file format, CERN OpenLab, 2011
  10. ^ Ingo Molnar, 'perf sched': Utility to capture, measure and analyze scheduler latencies and behavior, 17 Sep 2009
  11. ^ a b c Roberto A. Vitillo (LBNL). PERFORMANCE TOOLS DEVELOPMENTS, 16 June 2011, presentation from "Future computing in particle physics" conference
  12. ^ Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 3B: System Programming Guide, Part 2. Intel. June 2009. p. 19-2 vol. 3.
  13. ^ 6.4. Performance Counters for Linux (PCL) Tools and perf // RHEL Developer Guide
  14. ^ "Debian - Details of package linux-tools-2.6.32 in squeeze". Packages.debian.org. Retrieved 2014-03-31.
  15. ^ How to monitor the full range of CPU performance events // Bojan Nikolic, 2012
  16. ^ a b Robert Haas (PostgreSQL), perf: the good, the bad, the ugly // June 06, 2012
  17. ^ Michael Larabel (2013-05-15). "New Linux Kernel Vulnerability Exploited". Phoronix.
  18. ^ corbet (2013-05-15). "Local root vulnerability in the kernel". LWN.
  19. ^ Joe Damato (2013-05-20). "A closer look at a recent privilege escalation bug in Linux (CVE-2013-2094)".