World Library  
Flag as Inappropriate
Email this Article

Perf (Linux)

Article Id: WHEBN0036694312
Reproduction Date:

Title: Perf (Linux)  
Author: World Heritage Encyclopedia
Language: English
Subject: Linux kernel, Evdev, Kernel same-page merging, Debugfs, Mm tree
Publisher: World Heritage Encyclopedia

Perf (Linux)

Perf (Linux)
Written in C
Operating system Linux kernel
Type performance monitor and testing
License GNU GPL
Website _Page/Main.php/

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]


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.[6] Unlike oprofile or LTTng, no service daemons are needed, as most functionality is integrated into the kernel. The perf utility dumps raw data from the mmaped buffer to disk when the buffer becomes filled up. According to R. Vitillo (LBNL), profiling performed by perf involves a very low overhead.[6]

As of 2010, architectures that provide support for hardware counters include x86, PowerPC64, UltraSPARC (III and IV), ARM (v5, v6, v7, Cortex-A8 and -A9), Alpha EV56 and SuperH.[4] Usage of Last Branch Records,[7] a branch tracing implementation available in Intel CPUs since Pentium 4, is available as a patch.[6] Since version 3.14 of the Linux kernel mainline, released on March 31, 2014, perf also supports running average power limit (RAPL) for power consumption measurements, which is available as a feature of certain Intel CPUs.[8][9][10]

Perf is supported by Red Hat Enterprise Linux 6,[11] Debian Squeeze[12] and other popular Linux distributions.


perf is used with several subcommands:

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


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


  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. ^ a b c Roberto A. Vitillo (LBNL). PERFORMANCE TOOLS DEVELOPMENTS, 16 June 2011, presentation from "Future computing in particle physics" conference
  7. ^ 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. 
  8. ^ Jake Edge (2014-04-09). "Lots of new perf features".  
  9. ^ Jacob Pan (2013-04-02). "RAPL (Running Average Power Limit) driver".  
  10. ^ "kernel/git/torvalds/linux.git - Linux kernel source tree". 2014-01-20. Retrieved 2014-03-31. 
  11. ^ 6.4. Performance Counters for Linux (PCL) Tools and perf // RHEL Developer Guide
  12. ^ "Debian - Details of package linux-tools-2.6.32 in squeeze". Retrieved 2014-03-31. 
  13. ^ a b Urs Fässler perf file format, CERN OpenLab, 2011
  14. ^ Ingo Molnar, 'perf sched': Utility to capture, measure and analyze scheduler latencies and behavior, 17 Sep 2009
  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)". 

External links

  • perf's wiki on
  • Arnaldo Carvalho de Melo, The New Linux ’perf’ tools, presentation from Linux Kongress, September, 2010
  • Linux kernel profiling with perf tutorial
  • Hardware PMU support charts - check perf_event column
  • perf Examples by Brendan Gregg
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.