Perf (Linux)

Short description: Performance analyzing tool in Linux

PerfRepository| https://github.com/torvalds/linux/tree/master/tools/perf

|

Written in| C
Operating system| Linux kernel
Type| Performance monitor and testing
License| GNU GPL
Website| perf.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 in 2009.[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, two IBM engineers recognized perf (along with OProfile) as one of the two most commonly used performance counter profiling tools on Linux.[5]

## Contents

* 1 Implementation
* 2 Subcommands
* 3 Criticism
* 4 Security
* 5 See also
* 6 References
* 7 External links

## Implementation

The interface between the perf utility and the kernel consists of only one syscall and is done via a file descriptor and a mapped memory region.[6] Unlike LTTng or older versions of oprofile, no service daemons are needed, as most functionality is integrated into the kernel. The perf utility dumps raw data from the mapped 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 natively supported in many popular Linux distributions, including Red Hat Enterprise Linux (since its version 6 released in 2010)[11] and Debian in the linux-tools-common package (since Debian 6.0 (Squeeze) released in 2011).[12]

## 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[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

## Criticism

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]

## Security

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

* List of performance analysis tools
* OProfile
* Performance Application Programming Interface
* Profiling (computer programming)

## 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. ↑ 4.0 4.1 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. ↑ 6.0 6.1 6.2 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". LWN.net. https://lwn.net/Articles/593690/.
9. ↑ Jacob Pan (2013-04-02). "RAPL (Running Average Power Limit) driver". LWN.net. https://lwn.net/Articles/545745/.
10. ↑ "kernel/git/torvalds/linux.git - Linux kernel source tree". Git.kernel.org. 2014-01-20. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9326657abe1a83ed4b4f396b923ca1217fd50cba.
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". Packages.debian.org. http://packages.debian.org/squeeze/linux-tools-2.6.32.
13. ↑ 13.0 13.1 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. ↑ 16.0 16.1 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. https://www.phoronix.com/scan.php?page=news_item&px=MTM3MjA.
18. ↑ corbet (2013-05-15). "Local root vulnerability in the kernel". LWN. https://lwn.net/Articles/550678/.
19. ↑ Joe Damato (2013-05-20). "A closer look at a recent privilege escalation bug in Linux (CVE-2013-2094)". http://timetobleed.com/a-closer-look-at-a-recent-privilege-escalation-bug-in-linux-cve-2013-2094/.

## External links

* perf's wiki on kernel.org
* 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

* v
* t
* e

Linux kernel

Organization|

| Kernel|

* Linux Foundation
* Linux Mark Institute
* Linus's law
* Tanenbaum–Torvalds debate
* Tux
* SCO disputes
* Linaro
* GNU GPL v2
* menuconfig
* Supported computer architectures
* Kernel names
* Criticism

|

Support|

* Developers
* The Linux Programming Interface
* kernel.org
* LKML
* Linux conferences
* Users
* Linux User Group (LUG)

Technical|

| Debugging|

* CRIU
* ftrace
* kdump
* Linux kernel oops
* SystemTap
* BPF

|

Startup|

* vmlinux
* System.map
* dracut
* initrd
* initramfs

ABIs|

* Linux Standard Base
* x32 ABI

APIs|

| Of
userspace|

| FS,
daemons|

* devfs
* devpts
* debugfs
* procfs
* sysfs
* systemd
* udev
* Kmscon

|

Wrapper
libraries|

* C standard library
* glibc
* uClibc
* Bionic
* libhybris
* dietlibc
* EGLIBC
* klibc
* musl
* Newlib
* libcgroup
* libdrm
* libalsa
* libevdev
* libusb

kernel|

| System Call
Interface|

* POSIX
* ioctl
* select
* open
* read
* close
* sync
* …
* Linux-only
* futex
* epoll
* splice
* dnotify
* inotify
* readahead
* …

|

In-kernel|

* ALSA
* Crypto API
* DRM
* kernfs
* Memory barrier
* New API
* RCU
* Video4Linux

Components|

* Kernel modules
* BlueZ
* cgroups
* Console
* bcache
* Device mapper
* dm-cache
* dm-crypt
* DRM
* EDAC
* evdev
* Kernel same-page merging (KSM)
* LIO
* Framebuffer
* LVM
* KMS driver
* Netfilter
* Netlink
* nftables
* Network scheduler
* perf
* SLUB
* zram
* zswap

* Process and I/O schedulers:
* O(n) scheduler
* O(1) scheduler
* Completely Fair Scheduler (CFQ)
* Brain Fuck Scheduler
* Noop scheduler
* SCHED_DEADLINE

* Security Modules: AppArmor
* Exec Shield
* grsecurity
* PaX
* seccomp
* SELinux
* Smack
* Tomoyo Linux
* Linux PAM

* Device drivers
* 802.11
* graphics
* Raw device

* initramfs
* KernelCare
* kexec
* kGraft
* kpatch
* Ksplice

Variants|

* Mainline
* Linux kernel
* Linux-libre
* High-performance computing
* INK
* Compute Node Linux
* SLURM
* Real-time computing
* RTLinux
* RTAI
* Xenomai
* Carrier Grade Linux
* MMU-less
* μClinux
* PSXLinux

| Virtualization|

* Hypervisor
* KVM
* Xen
* OS-level virtualization
* Linux-VServer
* Lguest
* LXC
* OpenVZ
* Other
* L4Linux
* ELinOS
* User-mode Linux
* MkLinux
* coLinux

|

Adoption|

| Range
of use|

* Desktop
* Embedded
* Gaming
* Thin client:
* LTSP
* Thinstation
* Server:
* LAMP
* LYME-LYCE
* Devices

|

Adopters|

* List of Linux adopters
* GENIVI Alliance
* Proprietary software for Linux

* Category
* Commons
* Book
* Wikiversity
* Portal

* v
* t
* e

Linux

Linux kernel|

* History
* Kernel
* Linus's law
* Linux-libre
* Linux startup process
* Linux kernel oops
* Tux
* more…

Controversies|

* Criticism of Linux
* Criticism of desktop Linux
* GNU/Linux naming controversy
* Tanenbaum–Torvalds debate
* SCO and Linux

Distributions|

* General comparison
* Distributions list
* Netbook-specific comparison
* Distributions that run from RAM
* Lightweight
* Security-focused operating system
* Proprietary software for Linux
* Package manager
* Package format
* List of software package managers

Organizations|

* LinuxChix
* Linux Counter
* Linux Documentation Project
* Linux Foundation
* Linux Mark Institute
* Linux User Group (LUG)

Adoption|

* Adopters
* Desktop
* Embedded
* Gaming
* Mobile
* Range of use

Media|

* DistroWatch
* Free Software Magazine
* Full Circle
* Linux.com
* Linux Format
* Linux Gazette
* Linux Journal
* Linux Magazine
* LinuxUser
* Ubuntu User
* Linux Outlaws
* Linux Voice
* LugRadio
* LWN.net
* Open Source For You
* Phoronix
* Revolution OS
* The Code

* Linux
* Linux kernel features
* Portal
* WikiProject

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Perf (Linux). Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Perf_(Linux)&oldid=3041260"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template