OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / perf_event_open.2
index f7e9000..708880c 100644 (file)
@@ -24,7 +24,7 @@
 .\" This document is based on the perf_event.h header file, the
 .\" tools/perf/design.txt file, and a lot of bitter experience.
 .\"
-.TH PERF_EVENT_OPEN 2 2014-04-06 "Linux" "Linux Programmer's Manual"
+.TH PERF_EVENT_OPEN 2 2015-01-10 "Linux" "Linux Programmer's Manual"
 .SH NAME
 perf_event_open \- set up performance monitoring
 .SH SYNOPSIS
@@ -82,10 +82,10 @@ and
 arguments allow specifying which process and CPU to monitor:
 .TP
 .BR "pid == 0" " and " "cpu == \-1"
-This measures the current process/thread on any CPU.
+This measures the calling process/thread on any CPU.
 .TP
 .BR "pid == 0" " and " "cpu >= 0"
-This measures the current process/thread only
+This measures the calling process/thread only
 when running on the specified CPU.
 .TP
 .BR "pid > 0" " and " "cpu == \-1"
@@ -97,13 +97,13 @@ when running on the specified CPU.
 .TP
 .BR "pid == \-1" " and " "cpu >= 0"
 This measures all processes/threads on the specified CPU.
-Measurements such as this require the
+This requires
 .B CAP_SYS_ADMIN
 capability or a
 .I /proc/sys/kernel/perf_event_paranoid
 value of less than 1.
 .TP
-.BR pid==\-1 " and " cpu==\-1
+.BR "pid == \-1" " and " "cpu == \-1"
 This setting is invalid and will return an error.
 .P
 The
@@ -116,7 +116,7 @@ The rest of the group members are created with subsequent
 .BR perf_event_open ()
 calls with
 .IR group_fd
-being set to the fd of the group leader.
+being set to the file descriptor of the group leader.
 (A single event on its own is created with
 .IR group_fd " = \-1"
 and is considered to be a group with only 1 member.)
@@ -124,7 +124,7 @@ An event group is scheduled onto the CPU as a unit: it will
 be put onto the CPU only if all of the events in the group can be put onto
 the CPU.
 This means that the values of the member events can be
-meaningfully compared, added, divided (to get ratios), and so on, with each
+meaningfully compared\(emadded, divided (to get ratios), and so on\(emwith each
 other, since they have counted events for the same set of executed
 instructions.
 .P
@@ -132,7 +132,8 @@ The
 .I flags
 argument is formed by ORing together zero or more of the following values:
 .TP
-.BR PERF_FLAG_FD_CLOEXEC " (since Linux 3.14)."
+.BR PERF_FLAG_FD_CLOEXEC " (since Linux 3.14)"
+.\" commit a21b0b354d4ac39be691f51c53562e2c24443d9e
 This flag enables the close-on-exec flag for the created
 event file descriptor,
 so that the file descriptor is automatically closed on
@@ -141,25 +142,32 @@ Setting the close-on-exec flags at creation time, rather than later with
 .BR fcntl (2),
 avoids potential race conditions where the calling thread invokes
 .BR perf_event_open ()
+and
+.BR fcntl (2)
 at the same time as another thread calls
 .BR fork (2)
 then
 .BR execve (2).
 .TP
 .BR PERF_FLAG_FD_NO_GROUP
-.\" FIXME The following sentence is unclear
-This flag allows creating an event as part of an event group but
-having no group leader.
-It is unclear why this is useful.
-.\" FIXME So, why is it useful?
+This flag tells the event to ignore the
+.IR group_fd
+parameter except for the purpose of setting up output redirection
+using the
+.B PERF_FLAG_FD_OUTPUT
+flag.
 .TP
-.BR PERF_FLAG_FD_OUTPUT
-This flag reroutes the output from an event to the group leader.
+.BR PERF_FLAG_FD_OUTPUT " (broken since Linux 2.6.35)"
+.\" commit ac9721f3f54b27a16c7e1afb2481e7ee95a70318
+This flag re-routes the event's sampled output to instead
+be included in the mmap buffer of the event specified by
+.IR group_fd .
 .TP
-.BR PERF_FLAG_PID_CGROUP " (since Linux 2.6.39)."
+.BR PERF_FLAG_PID_CGROUP " (since Linux 2.6.39)"
+.\" commit e5d1367f17ba6a6fed5fd8b74e4d5720923e0c25
 This flag activates per-container system-wide monitoring.
 A container
-is an abstraction that isolates a set of resources for finer grain
+is an abstraction that isolates a set of resources for finer-grained
 control (CPUs, memory, etc.).
 In this mode, the event is measured
 only if the thread running on the monitored CPU belongs to the designated
@@ -187,43 +195,45 @@ for the event being created.
 .in +4n
 .nf
 struct perf_event_attr {
-    __u32     type;         /* Type of event */
-    __u32     size;         /* Size of attribute structure */
-    __u64     config;       /* Type-specific configuration */
+    __u32 type;         /* Type of event */
+    __u32 size;         /* Size of attribute structure */
+    __u64 config;       /* Type-specific configuration */
 
     union {
         __u64 sample_period;    /* Period of sampling */
         __u64 sample_freq;      /* Frequency of sampling */
     };
 
-    __u64     sample_type;  /* Specifies values included in sample */
-    __u64     read_format;  /* Specifies values returned in read */
-
-    __u64     disabled       : 1,   /* off by default */
-              inherit        : 1,   /* children inherit it */
-              pinned         : 1,   /* must always be on PMU */
-              exclusive      : 1,   /* only group on PMU */
-              exclude_user   : 1,   /* don't count user */
-              exclude_kernel : 1,   /* don't count kernel */
-              exclude_hv     : 1,   /* don't count hypervisor */
-              exclude_idle   : 1,   /* don't count when idle */
-              mmap           : 1,   /* include mmap data */
-              comm           : 1,   /* include comm data */
-              freq           : 1,   /* use freq, not period */
-              inherit_stat   : 1,   /* per task counts */
-              enable_on_exec : 1,   /* next exec enables */
-              task           : 1,   /* trace fork/exit */
-              watermark      : 1,   /* wakeup_watermark */
-              precise_ip     : 2,   /* skid constraint */
-              mmap_data      : 1,   /* non-exec mmap data */
-              sample_id_all  : 1,   /* sample_type all events */
-              exclude_host   : 1,   /* don't count in host */
-              exclude_guest  : 1,   /* don't count in guest */
-              exclude_callchain_kernel : 1,
-                                    /* exclude kernel callchains */
-              exclude_callchain_user   : 1,
-                                   /* exclude user callchains */
-              __reserved_1   : 41;
+    __u64 sample_type;  /* Specifies values included in sample */
+    __u64 read_format;  /* Specifies values returned in read */
+
+    __u64 disabled       : 1,   /* off by default */
+          inherit        : 1,   /* children inherit it */
+          pinned         : 1,   /* must always be on PMU */
+          exclusive      : 1,   /* only group on PMU */
+          exclude_user   : 1,   /* don't count user */
+          exclude_kernel : 1,   /* don't count kernel */
+          exclude_hv     : 1,   /* don't count hypervisor */
+          exclude_idle   : 1,   /* don't count when idle */
+          mmap           : 1,   /* include mmap data */
+          comm           : 1,   /* include comm data */
+          freq           : 1,   /* use freq, not period */
+          inherit_stat   : 1,   /* per task counts */
+          enable_on_exec : 1,   /* next exec enables */
+          task           : 1,   /* trace fork/exit */
+          watermark      : 1,   /* wakeup_watermark */
+          precise_ip     : 2,   /* skid constraint */
+          mmap_data      : 1,   /* non-exec mmap data */
+          sample_id_all  : 1,   /* sample_type all events */
+          exclude_host   : 1,   /* don't count in host */
+          exclude_guest  : 1,   /* don't count in guest */
+          exclude_callchain_kernel : 1,
+                                /* exclude kernel callchains */
+          exclude_callchain_user   : 1,
+                                /* exclude user callchains */
+          mmap2          :  1,  /* include mmap with inode data */
+          comm_exec      :  1,  /* flag comm events that are due to exec */
+          __reserved_1   : 39;
 
     union {
         __u32 wakeup_events;    /* wakeup every n events */
@@ -241,11 +251,11 @@ struct perf_event_attr {
         __u64 bp_len;           /* breakpoint length */
         __u64 config2;          /* extension of config1 */
     };
-    __u64   branch_sample_type; /* enum perf_branch_sample_type */
-    __u64   sample_regs_user;   /* user regs to dump on samples */
-    __u32   sample_stack_user;  /* size of stack to dump on
+    __u64 branch_sample_type;   /* enum perf_branch_sample_type */
+    __u64 sample_regs_user;     /* user regs to dump on samples */
+    __u32 sample_stack_user;    /* size of stack to dump on
                                    samples */
-    __u32   __reserved_2;       /* Align to u64 */
+    __u32 __reserved_2;         /* Align to u64 */
 
 };
 .fi
@@ -286,12 +296,14 @@ This indicates a "raw" implementation-specific event in the
 .IR config " field."
 .TP
 .BR PERF_TYPE_BREAKPOINT " (since Linux 2.6.33)"
+.\" commit 24f1e32c60c45c89a997c73395b69c8af6f0a84e
 This indicates a hardware breakpoint as provided by the CPU.
 Breakpoints can be read/write accesses to an address as well as
 execution of an instruction address.
 .TP
 .RB "dynamic PMU"
-Since Linux 2.6.39,
+Since Linux 2.6.38,
+.\" commit 2e80a82a49c4c7eca4e35734380f28298ba5db19
 .BR perf_event_open ()
 can support multiple PMUs.
 To enable this, a value exported by the kernel can be used in the
@@ -324,15 +336,20 @@ The related define
 is set to 64; this was the size of the first published struct.
 .B PERF_ATTR_SIZE_VER1
 is 72, corresponding to the addition of breakpoints in Linux 2.6.33.
+.\" commit cb5d76999029ae7a517cb07dfa732c1b5a934fc2
+.\" this was added much later when PERF_ATTR_SIZE_VER2 happened
+.\" but the actual attr_size had increased in 2.6.33
 .B PERF_ATTR_SIZE_VER2
 is 80 corresponding to the addition of branch sampling in Linux 3.4.
-.B PERF_ATR_SIZE_VER3
+.\" commit cb5d76999029ae7a517cb07dfa732c1b5a934fc2
+.B PERF_ATTR_SIZE_VER3
 is 96 corresponding to the addition
 of
 .I sample_regs_user
 and
 .I sample_stack_user
 in Linux 3.7.
+.\" commit 1659d129ed014b715b0b2120e6fd929bdd33ed03
 .TP
 .I "config"
 This specifies which event you want, in conjunction with
@@ -345,12 +362,6 @@ fields are also taken into account in cases where 64 bits is not
 enough to fully specify the event.
 The encoding of these fields are event dependent.
 
-The most significant bit (bit 63) of
-.I config
-signifies CPU-specific (raw) counter configuration data;
-if the most significant bit is unset, the next 7 bits are an event
-type and the rest of the bits are the event identifier.
-
 There are various ways to set the
 .I config
 field that are dependent on the value of the previously
@@ -398,8 +409,9 @@ event to calculate cache miss rates.
 .TP
 .B PERF_COUNT_HW_BRANCH_INSTRUCTIONS
 Retired branch instructions.
-Prior to Linux 2.6.34, this used
+Prior to Linux 2.6.35, this used
 the wrong event on AMD processors.
+.\" commit f287d332ce835f77a4f5077d2c0ef1e3f9ea42d2
 .TP
 .B PERF_COUNT_HW_BRANCH_MISSES
 Mispredicted branch instructions.
@@ -408,12 +420,15 @@ Mispredicted branch instructions.
 Bus cycles, which can be different from total cycles.
 .TP
 .BR PERF_COUNT_HW_STALLED_CYCLES_FRONTEND " (since Linux 3.0)"
+.\" commit 8f62242246351b5a4bc0c1f00c0c7003edea128a
 Stalled cycles during issue.
 .TP
 .BR PERF_COUNT_HW_STALLED_CYCLES_BACKEND  " (since Linux 3.0)"
+.\" commit 8f62242246351b5a4bc0c1f00c0c7003edea128a
 Stalled cycles during retirement.
 .TP
 .BR PERF_COUNT_HW_REF_CPU_CYCLES  " (since Linux 3.3)"
+.\" commit c37e17497e01fc0f5d2d6feb5723b210b3ab8890
 Total cycles; not affected by CPU frequency scaling.
 .RE
 .IP
@@ -440,6 +455,7 @@ This reports the number of page faults.
 This counts context switches.
 Until Linux 2.6.34, these were all reported as user-space
 events, after that they are reported as happening in the kernel.
+.\" commit e49a5bd38159dfb1928fd25b173bc9de4bbadb21
 .TP
 .B PERF_COUNT_SW_CPU_MIGRATIONS
 This reports the number of times the process
@@ -454,18 +470,21 @@ This counts the number of major page faults.
 These required disk I/O to handle.
 .TP
 .BR PERF_COUNT_SW_ALIGNMENT_FAULTS " (since Linux 2.6.33)"
+.\" commit f7d7986060b2890fc26db6ab5203efbd33aa2497
 This counts the number of alignment faults.
 These happen when unaligned memory accesses happen; the kernel
 can handle these but it reduces performance.
 This happens only on some architectures (never on x86).
 .TP
 .BR PERF_COUNT_SW_EMULATION_FAULTS " (since Linux 2.6.33)"
+.\" commit f7d7986060b2890fc26db6ab5203efbd33aa2497
 This counts the number of emulation faults.
 The kernel sometimes traps on unimplemented instructions
 and emulates them for user space.
 This can negatively impact performance.
 .TP
 .BR PERF_COUNT_SW_DUMMY " (since Linux 3.12)"
+.\" commit fa0097ee690693006ab1aea6c01ad3c851b65c77
 This is a placeholder event that counts nothing.
 Informational sample record types such as mmap or comm
 must be associated with an active event.
@@ -525,7 +544,8 @@ for measuring the Instruction TLB
 .B PERF_COUNT_HW_CACHE_BPU
 for measuring the branch prediction unit
 .TP
-.BR PERF_COUNT_HW_CACHE_NODE " (since Linux 3.0)"
+.BR PERF_COUNT_HW_CACHE_NODE " (since Linux 3.1)"
+.\" commit 89d6c0b5bdbb1927775584dcf532d98b3efe1477
 for measuring local memory accesses
 .RE
 .P
@@ -584,16 +604,16 @@ Its parameters are set in other places.
 .RE
 .TP
 .IR sample_period ", " sample_freq
-A "sampling" counter is one that generates an interrupt
+A "sampling" event is one that generates an overflow notification
 every N events, where N is given by
 .IR sample_period .
-A sampling counter has
+A sampling event has
 .IR sample_period " > 0."
-When an overflow interrupt occurs, requested data is recorded
+When an overflow occurs, requested data is recorded
 in the mmap buffer.
 The
 .I sample_type
-field controls what data is recorded on each interrupt.
+field controls what data is recorded on each overflow.
 
 .I sample_freq
 can be used if you wish to use frequency rather than period.
@@ -658,6 +678,7 @@ Records additional data, if applicable.
 Usually returned by tracepoint events.
 .TP
 .BR PERF_SAMPLE_BRANCH_STACK " (since Linux 3.4)"
+.\" commit bce38cd53e5ddba9cb6d708c4ef3d04a4016ec7e
 This provides a record of recent branches, as provided
 by CPU branch sampling hardware (such as Intel Last Branch Record).
 Not all hardware supports this feature.
@@ -667,25 +688,30 @@ See the
 field for how to filter which branches are reported.
 .TP
 .BR PERF_SAMPLE_REGS_USER " (since Linux 3.7)"
+.\" commit 4018994f3d8785275ef0e7391b75c3462c029e56
 Records the current user-level CPU register state
 (the values in the process before the kernel was called).
 .TP
 .BR PERF_SAMPLE_STACK_USER " (since Linux 3.7)"
+.\" commit c5ebcedb566ef17bda7b02686e0d658a7bb42ee7
 Records the user level stack, allowing stack unwinding.
 .TP
 .BR PERF_SAMPLE_WEIGHT " (since Linux 3.10)"
+.\" commit c3feedf2aaf9ac8bad6f19f5d21e4ee0b4b87e9c
 Records a hardware provided weight value that expresses how
 costly the sampled event was.
 This allows the hardware to highlight expensive events in
 a profile.
 .TP
 .BR PERF_SAMPLE_DATA_SRC " (since Linux 3.10)"
+.\" commit d6be9ad6c960f43800a6f118932bc8a5a4eadcd1
 Records the data source: where in the memory hierarchy
 the data associated with the sampled instruction came from.
-This is only available if the underlying hardware
+This is available only if the underlying hardware
 supports this feature.
 .TP
 .BR PERF_SAMPLE_IDENTIFIER " (since Linux 3.12)"
+.\" commit ff3d527cebc1fa3707c617bfe9e74f53fcfb0955
 Places the
 .B SAMPLE_ID
 value in a fixed position in the record,
@@ -704,7 +730,7 @@ the format could not be found without knowing what
 event the sample belonged to (causing a circular
 dependency).
 
-This new
+The
 .B PERF_SAMPLE_IDENTIFIER
 setting makes the event stream always parsable
 by putting
@@ -714,7 +740,8 @@ it means having duplicate
 .B SAMPLE_ID
 values in records.
 .TP
-.BR PERF_SAMPLE_TRANSACTION " (Since Linux 3.13)"
+.BR PERF_SAMPLE_TRANSACTION " (since Linux 3.13)"
+.\" commit fdfbbd07e91f8fe387140776f3fd94605f0c89e5
 Records reasons for transactional memory abort events
 (for example, from Intel TSX transactional memory support).
 
@@ -747,7 +774,7 @@ Adds the 64-bit
 .I time_running
 field.
 This can be used to calculate estimated totals if
-the PMU is overcommitted and  multiplexing is happening.
+the PMU is overcommitted and multiplexing is happening.
 .TP
 .B PERF_FORMAT_ID
 Adds a 64-bit unique value that corresponds to the event group.
@@ -858,9 +885,17 @@ bit enables tracking of process command name as modified by the
 .BR exec (2)
 and
 .BR prctl (PR_SET_NAME)
-system calls.
-Unfortunately for tools,
-there is no way to distinguish one system call versus the other.
+system calls as well as writing to
+.IR /proc/self/comm .
+If the
+.I comm_exec
+flag is also successfully set (possible since Linux 3.16),
+.\" commit 82b897782d10fcc4930c9d4a15b175348fdd2871
+then the misc flag
+.B PERF_RECORD_MISC_COMM_EXEC
+can be used to differentiate the
+.BR exec (2)
+case from the others.
 .TP
 .IR "freq"
 If this bit is set, then
@@ -886,14 +921,15 @@ If this bit is set, then
 fork/exit notifications are included in the ring buffer.
 .TP
 .IR "watermark"
-If set, have a sampling interrupt happen when we cross the
+If set, have an overflow notification happen when we cross the
 .I wakeup_watermark
 boundary.
-Otherwise interrupts happen after
+Otherwise, overflow notifications happen after
 .I wakeup_events
 samples.
 .TP
 .IR "precise_ip" " (since Linux 2.6.35)"
+.\" commit ab608344bcbde4f55ec4cd911b686b0ce3eae076
 This controls the amount of skid.
 Skid is how many instructions
 execute between an event of interest happening and the kernel
@@ -926,6 +962,7 @@ See also
 .RE
 .TP
 .IR "mmap_data" " (since Linux 2.6.36)"
+.\" commit 3af9e859281bda7eb7c20b51879cf43aa788ac2e
 The counterpart of the
 .I mmap
 field.
@@ -938,6 +975,7 @@ calls that do not have
 set (for example data and SysV shared memory).
 .TP
 .IR "sample_id_all" " (since Linux 2.6.38)"
+.\" commit c980d1091810df13f21aabbce545fd98f545bbf7
 If set, then TID, TIME, ID, STREAM_ID, and CPU can
 additionally be included in
 .RB non- PERF_RECORD_SAMPLE s
@@ -967,38 +1005,78 @@ struct sample_id {
 .fi
 .TP
 .IR "exclude_host" " (since Linux 3.2)"
+.\" commit a240f76165e6255384d4bdb8139895fac7988799
 Do not measure time spent in VM host.
 .TP
 .IR "exclude_guest" " (since Linux 3.2)"
+.\" commit a240f76165e6255384d4bdb8139895fac7988799
 Do not measure time spent in VM guest.
 .TP
 .IR "exclude_callchain_kernel" " (since Linux 3.7)"
+.\" commit d077526485d5c9b12fe85d0b2b3b7041e6bc5f91
 Do not include kernel callchains.
 .TP
 .IR "exclude_callchain_user" " (since Linux 3.7)"
+.\" commit d077526485d5c9b12fe85d0b2b3b7041e6bc5f91
 Do not include user callchains.
 .TP
+.IR "mmap2" " (since Linux 3.16)"
+.\" commit 13d7a2410fa637f450a29ecb515ac318ee40c741
+.\" This is tricky; was committed during 3.12 development
+.\" but right before release was disabled.
+.\" So while you could select mmap2 starting with 3.12
+.\" it did not work until 3.16
+.\" commit a5a5ba72843dd05f991184d6cb9a4471acce1005
+Generate an extended executable mmap record that contains enough
+additional information to uniquely identify shared mappings.
+The
+.I mmap
+flag must also be set for this to work.
+.TP
+.IR "comm_exec" " (since Linux 3.16)"
+.\" commit 82b897782d10fcc4930c9d4a15b175348fdd2871
+This is purely a feature-detection flag, it does not change
+kernel behavior.
+If this flag can successfully be set, then, when
+.I comm
+is enabled, the
+.B PERF_RECORD_MISC_COMM_EXEC
+flag will be set in the
+.I misc
+field of a comm record header if the rename event being
+reported was caused by a call to
+.BR exec (2).
+This allows tools to distinguish between the various
+types of process renaming.
+.TP
 .IR "wakeup_events" ", " "wakeup_watermark"
 This union sets how many samples
 .RI ( wakeup_events )
 or bytes
 .RI ( wakeup_watermark )
-happen before an overflow signal happens.
+happen before an overflow notification happens.
 Which one is used is selected by the
 .I watermark
-bitflag.
+bit flag.
 
 .I wakeup_events
-only counts
+counts only
 .B PERF_RECORD_SAMPLE
 record types.
-To  receive a signal for every incoming
+To receive overflow notification for all
 .B PERF_RECORD
-type set
+types choose watermark and set
 .I wakeup_watermark
 to 1.
+
+Prior to Linux 3.0 setting
+.\" commit f506b3dc0ec454a16d40cab9ee5d75435b39dc50
+.I wakeup_events
+to 0 resulted in no overflow notifications;
+more recent kernels treat 0 the same as 1.
 .TP
 .IR "bp_type" " (since Linux 2.6.33)"
+.\" commit 24f1e32c60c45c89a997c73395b69c8af6f0a84e
 This chooses the breakpoint type.
 It is one of:
 .RS
@@ -1029,6 +1107,7 @@ is not allowed.
 .RE
 .TP
 .IR "bp_addr" " (since Linux 2.6.33)"
+.\" commit 24f1e32c60c45c89a997c73395b69c8af6f0a84e
 .I bp_addr
 address of the breakpoint.
 For execution breakpoints this is the memory address of the instruction
@@ -1036,6 +1115,7 @@ of interest; for read and write breakpoints it is the memory address
 of the memory location of interest.
 .TP
 .IR "config1" " (since Linux 2.6.39)"
+.\" commit a7e3ed1e470116c9d12c2f778431a481a6be8ab6
 .I config1
 is used for setting events that need an extra register or otherwise
 do not fit in the regular config field.
@@ -1043,6 +1123,7 @@ Raw OFFCORE_EVENTS on Nehalem/Westmere/SandyBridge use this field
 on 3.3 and later kernels.
 .TP
 .IR "bp_len" " (since Linux 2.6.33)"
+.\" commit 24f1e32c60c45c89a997c73395b69c8af6f0a84e
 .I bp_len
 is the length of the breakpoint being measured if
 .I type
@@ -1057,6 +1138,7 @@ For an execution breakpoint, set this to
 .IR sizeof(long) .
 .TP
 .IR "config2" " (since Linux 2.6.39)"
+.\" commit a7e3ed1e470116c9d12c2f778431a481a6be8ab6
 
 .I config2
 is a further extension of the
@@ -1064,6 +1146,7 @@ is a further extension of the
 field.
 .TP
 .IR "branch_sample_type" " (since Linux 3.4)"
+.\" commit bce38cd53e5ddba9cb6d708c4ef3d04a4016ec7e
 If
 .B PERF_SAMPLE_BRANCH_STACK
 is enabled, then this specifies what branches to include
@@ -1105,31 +1188,40 @@ Any return branch.
 .B PERF_SAMPLE_BRANCH_IND_CALL
 Indirect calls.
 .TP
+.BR PERF_SAMPLE_BRANCH_COND " (since Linux 3.16)"
+.\" commit bac52139f0b7ab31330e98fd87fc5a2664951050
+Conditional branches.
+.TP
 .BR PERF_SAMPLE_BRANCH_ABORT_TX " (since Linux 3.11)"
+.\" commit 135c5612c460f89657c4698fe2ea753f6f667963
 Transactional memory aborts.
 .TP
 .BR PERF_SAMPLE_BRANCH_IN_TX " (since Linux 3.11)"
+.\" commit 135c5612c460f89657c4698fe2ea753f6f667963
 Branch in transactional memory transaction.
 .TP
 .BR PERF_SAMPLE_BRANCH_NO_TX " (since Linux 3.11)"
+.\" commit 135c5612c460f89657c4698fe2ea753f6f667963
 Branch not in transactional memory transaction.
 .RE
 
 .TP
 .IR "sample_regs_user" " (since Linux 3.7)"
+.\" commit 4018994f3d8785275ef0e7391b75c3462c029e56
 This bit mask defines the set of user CPU registers to dump on samples.
 The layout of the register mask is architecture-specific and
 described in the kernel header
 .IR arch/ARCH/include/uapi/asm/perf_regs.h .
 .TP
 .IR "sample_stack_user" " (since Linux 3.7)"
+.\" commit c5ebcedb566ef17bda7b02686e0d658a7bb42ee7
 This defines the size of the user stack to dump if
 .B PERF_SAMPLE_STACK_USER
 is specified.
 .SS Reading results
 Once a
 .BR perf_event_open ()
-file descriptor  has been opened, the values
+file descriptor has been opened, the values
 of the events can be read from the file descriptor.
 The values that are there are specified by the
 .I read_format
@@ -1154,7 +1246,7 @@ struct read_format {
     u64 nr;            /* The number of events */
     u64 time_enabled;  /* if PERF_FORMAT_TOTAL_TIME_ENABLED */
     u64 time_running;  /* if PERF_FORMAT_TOTAL_TIME_RUNNING */
-    struct
+    struct {
         u64 value;     /* The value of the event */
         u64 id;        /* if PERF_FORMAT_ID */
     } values[nr];
@@ -1203,7 +1295,7 @@ values can be used to scale an estimated value for the count.
 An unsigned 64-bit value containing the counter result.
 .TP
 .I id
-A globally unique value for this particular event, only there if
+A globally unique value for this particular event, only present if
 .B PERF_FORMAT_ID
 was specified in
 .IR read_format .
@@ -1232,35 +1324,35 @@ The structure of the first metadata mmap page is as follows:
 .in +4n
 .nf
 struct perf_event_mmap_page {
-    __u32 version;          /* version number of this structure */
-    __u32 compat_version;   /* lowest version this is compat with */
-    __u32 lock;             /* seqlock for synchronization */
-    __u32 index;            /* hardware counter identifier */
-    __s64 offset;           /* add to hardware counter value */
-    __u64 time_enabled;     /* time event active */
-    __u64 time_running;     /* time event on CPU */
+    __u32 version;        /* version number of this structure */
+    __u32 compat_version; /* lowest version this is compat with */
+    __u32 lock;           /* seqlock for synchronization */
+    __u32 index;          /* hardware counter identifier */
+    __s64 offset;         /* add to hardware counter value */
+    __u64 time_enabled;   /* time event active */
+    __u64 time_running;   /* time event on CPU */
     union {
         __u64   capabilities;
         struct {
-            __u64   cap_usr_time / cap_usr_rdpmc / cap_bit0 : 1,
-                    cap_bit0_is_deprecated : 1,
-                    cap_user_rdpmc         : 1,
-                    cap_user_time          : 1,
-                    cap_user_time_zero     : 1,
+            __u64 cap_usr_time / cap_usr_rdpmc / cap_bit0 : 1,
+                  cap_bit0_is_deprecated : 1,
+                  cap_user_rdpmc         : 1,
+                  cap_user_time          : 1,
+                  cap_user_time_zero     : 1,
         };
     };
-    __u16   pmc_width;
-    __u16   time_shift;
-    __u32   time_mult;
-    __u64   time_offset;
-    __u64   __reserved[120];   /* Pad to 1k */
-    __u64   data_head;         /* head in the data section */
-    __u64   data_tail;         /* user-space written tail */
+    __u16 pmc_width;
+    __u16 time_shift;
+    __u32 time_mult;
+    __u64 time_offset;
+    __u64 __reserved[120];   /* Pad to 1k */
+    __u64 data_head;         /* head in the data section */
+    __u64 data_tail;         /* user-space written tail */
 }
 .fi
 .in
 
-The following looks at the fields in the
+The following list describes the fields in the
 .I perf_event_mmap_page
 structure in more detail:
 .TP
@@ -1288,6 +1380,7 @@ Time the event was active.
 Time the event was running.
 .TP
 .IR cap_usr_time " / " cap_usr_rdpmc " / " cap_bit0 " (since Linux 3.4)"
+.\" commit c7206205d00ab375839bd6c7ddb247d600693c09
 There was a bug in the definition of
 .I cap_usr_time
 and
@@ -1300,9 +1393,10 @@ or
 .I cap_usr_rdpmc
 were actually set.
 
-Starting with 3.12 these are renamed to
+Starting with Linux 3.12, these are renamed to
+.\" commit fa7315871046b9a4c48627905691dbde57e51033
 .I cap_bit0
-and you should use the new
+and you should use the
 .I cap_user_time
 and
 .I cap_user_rdpmc
@@ -1310,6 +1404,7 @@ fields instead.
 
 .TP
 .IR cap_bit0_is_deprecated " (since Linux 3.12)"
+.\" commit fa7315871046b9a4c48627905691dbde57e51033
 If set, this bit indicates that the kernel supports
 the properly separated
 .I cap_user_time
@@ -1326,6 +1421,7 @@ be used with caution.
 
 .TP
 .IR cap_user_rdpmc " (since Linux 3.12)"
+.\" commit fa7315871046b9a4c48627905691dbde57e51033
 If the hardware supports user-space read of performance counters
 without syscall (this is the "rdpmc" instruction on x86), then
 the following code can be used to do a read:
@@ -1362,11 +1458,13 @@ do {
 .fi
 .in
 .TP
-.I cap_user_time " (since Linux 3.12)"
+.IR cap_user_time " (since Linux 3.12)"
+.\" commit fa7315871046b9a4c48627905691dbde57e51033
 This bit indicates the hardware has a constant, nonstop
 timestamp counter (TSC on x86).
 .TP
 .IR cap_user_time_zero " (since Linux 3.12)"
+.\" commit fa7315871046b9a4c48627905691dbde57e51033
 Indicates the presence of
 .I time_zero
 which allows mapping timestamp values to
@@ -1424,19 +1522,23 @@ enabled and possible running (if idx), improving the scaling:
 .fi
 .TP
 .IR time_zero " (since Linux 3.12)"
+.\" commit fa7315871046b9a4c48627905691dbde57e51033
 
 If
 .I cap_usr_time_zero
 is set, then the hardware clock (the TSC timestamp counter on x86)
 can be calculated from the
 .IR time_zero ", " time_mult ", and " time_shift " values:"
+
 .nf
     time = timestamp - time_zero;
     quot = time / time_mult;
     rem  = time % time_mult;
     cyc = (quot << time_shift) + (rem << time_shift) / time_mult;
 .fi
+
 And vice versa:
+
 .nf
     quot = cyc >> time_shift;
     rem  = cyc & ((1 << time_shift) - 1);
@@ -1450,7 +1552,9 @@ The value continuously increases, it does not wrap.
 The value needs to be manually wrapped by the size of the mmap buffer
 before accessing the samples.
 
-On SMP-capable platforms, after reading the data_head value,
+On SMP-capable platforms, after reading the
+.I data_head
+value,
 user space should issue an rmb().
 .TP
 .I data_tail
@@ -1472,7 +1576,7 @@ an event took place (TID, TIME, ID, CPU, STREAM_ID) described in
 below, it will be stashed just after the
 .I perf_event_header
 and the fields already present for the existing
-fields, that  is, at the end of the payload.
+fields, that is, at the end of the payload.
 That way a newer perf.data
 file will be supported by older perf tools, with these new optional
 fields being ignored.
@@ -1521,20 +1625,35 @@ Sample happened in user code.
 .B PERF_RECORD_MISC_HYPERVISOR
 Sample happened in the hypervisor.
 .TP
-.B PERF_RECORD_MISC_GUEST_KERNEL
+.BR PERF_RECORD_MISC_GUEST_KERNEL " (since Linux 2.6.35)"
+.\" commit 39447b386c846bbf1c56f6403c5282837486200f
 Sample happened in the guest kernel.
 .TP
-.B PERF_RECORD_MISC_GUEST_USER
+.B PERF_RECORD_MISC_GUEST_USER " (since Linux 2.6.35)"
+.\" commit 39447b386c846bbf1c56f6403c5282837486200f
 Sample happened in guest user code.
 .RE
 
 .RS
 In addition, one of the following bits can be set:
 .TP
-.B PERF_RECORD_MISC_MMAP_DATA
+.BR PERF_RECORD_MISC_MMAP_DATA " (since Linux 3.10)"
+.\" commit 2fe85427e3bf65d791700d065132772fc26e4d75
 This is set when the mapping is not executable;
 otherwise the mapping is executable.
 .TP
+.BR PERF_RECORD_MISC_COMM_EXEC " (since Linux 3.16)"
+.\" commit 82b897782d10fcc4930c9d4a15b175348fdd2871
+This is set for a
+.B PERF_RECORD_COMM
+record on kernels more recent than Linux 3.16
+if a process name change was caused by an
+.BR exec (2)
+system call.
+It is an alias for
+.B PERF_RECORD_MISC_MMAP_DATA
+since the two values would not be set in the same record.
+.TP
 .B PERF_RECORD_MISC_EXACT_IP
 This indicates that the content of
 .B PERF_SAMPLE_IP
@@ -1543,7 +1662,8 @@ to the actual instruction that triggered the event.
 See also
 .IR perf_event_attr.precise_ip .
 .TP
-.B PERF_RECORD_MISC_EXT_RESERVED
+.BR PERF_RECORD_MISC_EXT_RESERVED " (since Linux 2.6.35)"
+.\" commit 1676b8a077c352085d52578fb4f29350b58b6e74
 This indicates there is extended data available (currently not used).
 .RE
 .TP
@@ -1577,6 +1697,23 @@ struct {
 };
 .fi
 .in
+.RS
+.TP
+.I pid
+is the process ID.
+.TP
+.I tid
+is the thread ID.
+.TP
+.I addr
+is the address of the allocated memory.
+.I len
+is the length of the allocated memory.
+.I pgoff
+is the page offset of the allocated memory.
+.I filename
+is a string describing the backing of the allocated memory.
+.RE
 .TP
 .B PERF_RECORD_LOST
 This record indicates when events are lost.
@@ -1607,12 +1744,24 @@ This record indicates a change in the process name.
 .nf
 struct {
     struct perf_event_header header;
-    u32 pid, tid;
+    u32 pid;
+    u32 tid;
     char comm[];
     struct sample_id sample_id;
 };
 .fi
 .in
+.RS
+.TP
+.I pid
+is the process ID.
+.TP
+.I tid
+is the thread ID.
+.TP
+.I comm
+is a string containing the new name of the process.
+.RE
 .TP
 .B PERF_RECORD_EXIT
 This record indicates a process exit event.
@@ -1832,9 +1981,11 @@ The branch target was mispredicted.
 The branch target was predicted.
 .TP
 .IR in_tx " (since Linux 3.11)"
+.\" commit 135c5612c460f89657c4698fe2ea753f6f667963
 The branch was in a transactional memory transaction.
 .TP
 .IR abort " (since Linux 3.11)"
+.\" commit 135c5612c460f89657c4698fe2ea753f6f667963
 The branch was in an aborted transactional memory transaction.
 
 .P
@@ -1878,13 +2029,15 @@ bit mask.
 .IR size ", " data[size] ", " dyn_size
 If
 .B PERF_SAMPLE_STACK_USER
-is enabled, then record the user stack to enable backtracing.
+is enabled, then the user stack is recorded.
+This can be used to generate stack backtraces.
 .I size
 is the size requested by the user in
-.I stack_user_size
+.I sample_stack_user
 or else the maximum record size.
 .I data
-is the stack data.
+is the stack data (a raw dump of the memory pointed to by the
+stack pointer at the time of sampling).
 .I dyn_size
 is the amount of data actually dumped (can be less than
 .IR size ).
@@ -1928,7 +2081,9 @@ Executable code
 .PD
 .TP
 .I mem_lvl
-Memory hierarchy level hit or miss, a bitwise combination of:
+Memory hierarchy level hit or miss, a bitwise combination of
+the following, shifted left by
+.BR PERF_MEM_LVL_SHIFT :
 
 .PD 0
 .RS
@@ -1978,7 +2133,8 @@ Uncached memory
 .PD
 .TP
 .I mem_snoop
-Snoop mode, a bitwise combination of:
+Snoop mode, a bitwise combination of the following, shifted left by
+.BR PERF_MEM_SNOOP_SHIFT :
 
 .PD 0
 .RS
@@ -2001,7 +2157,8 @@ Snoop hit modified
 .PD
 .TP
 .I mem_lock
-Lock instruction, a bitwise combination of:
+Lock instruction, a bitwise combination of the following, shifted left by
+.BR PERF_MEM_LOCK_SHIFT :
 
 .PD 0
 .RS
@@ -2015,7 +2172,9 @@ Locked transaction
 .PD
 .TP
 .I mem_dtlb
-TLB access hit or miss, a bitwise combination of:
+TLB access hit or miss, a bitwise combination of the following, shifted
+left by
+.BR PERF_MEM_TLB_SHIFT :
 
 .PD 0
 .RS
@@ -2084,52 +2243,124 @@ the high 32 bits of the field by shifting right by
 and masking with
 .BR PERF_TXN_ABORT_MASK .
 .RE
+.TP
+.B PERF_RECORD_MMAP2
+This record includes extended information on
+.BR mmap (2)
+calls returning executable mappings.
+The format is similar to that of the
+.B PERF_RECORD_MMAP
+record, but includes extra values that allow uniquely identifying
+shared mappings.
+
+.in +4n
+.nf
+struct {
+    struct perf_event_header header;
+    u32 pid;
+    u32 tid;
+    u64 addr;
+    u64 len;
+    u64 pgoff;
+    u32 maj;
+    u32 min;
+    u64 ino;
+    u64 ino_generation;
+    u32 prot;
+    u32 flags;
+    char filename[];
+    struct sample_id sample_id;
+};
+.fi
+.RS
+.TP
+.I pid
+is the process ID.
+.TP
+.I tid
+is the thread ID.
+.TP
+.I addr
+is the address of the allocated memory.
+.TP
+.I len
+is the length of the allocated memory.
+.TP
+.I pgoff
+is the page offset of the allocated memory.
+.TP
+.I maj
+is the major ID of the underlying device.
+.TP
+.I min
+is the minor ID of the underlying device.
+.TP
+.I ino
+is the inode number.
+.TP
+.I ino_generation
+is the inode generation.
+.TP
+.I prot
+is the protection information.
+.TP
+.I flags
+is the flags information.
+.TP
+.I filename
+is a string describing the backing of the allocated memory.
+.RE
 .RE
-.SS Signal overflow
-Events can be set to deliver a signal when a threshold is crossed.
-The signal handler is set up using the
+.SS Overflow handling
+Events can be set to notify when a threshold is crossed,
+indicating an overflow.
+Overflow conditions can be captured by monitoring the
+event file descriptor with
 .BR poll (2),
 .BR select (2),
-.BR epoll (2)
-and
-.BR fcntl (2),
-system calls.
+or
+.BR epoll (2).
+Alternately, a SIGIO signal handler can be created and
+the event configured with
+.BR fcntl (2)
+to generate SIGIO signals.
 
-To generate signals, sampling must be enabled
+Overflows are generated only by sampling events
 .RI ( sample_period
 must have a nonzero value).
 
-There are two ways to generate signals.
+There are two ways to generate overflow notifications.
 
 The first is to set a
 .I wakeup_events
 or
 .I wakeup_watermark
-value that will generate a signal if a certain number of samples
+value that will trigger if a certain number of samples
 or bytes have been written to the mmap ring buffer.
-In this case, a signal of type
+In this case
 .B POLL_IN
-is sent.
+is indicated.
 
 The other way is by use of the
 .B PERF_EVENT_IOC_REFRESH
 ioctl.
 This ioctl adds to a counter that decrements each time the event overflows.
-When nonzero, a
+When nonzero,
 .B POLL_IN
-signal is sent on overflow, but
-once the value reaches 0, a signal is sent of type
+is indicated, but
+once the counter reaches 0
 .B POLL_HUP
-and
+is indicated and
 the underlying event is disabled.
 
-Note: on newer kernels (definitely noticed with 3.2)
-.\" FIXME(Vince) : Find out when this was introduced
-a signal is provided for every overflow, even if
-.I wakeup_events
-is not set.
+Starting with Linux 3.18,
+.\" commit 179033b3e064d2cd3f5f9945e76b0a0f0fbf4883
+.B POLL_HUP
+is indicated if the event being monitored is attached to a different
+process and that process exits.
 .SS rdpmc instruction
 Starting with Linux 3.4 on x86, you can use the
+.\" commit c7206205d00ab375839bd6c7ddb247d600693c09
 .I rdpmc
 instruction to get low-latency reads without having to enter the kernel.
 Note that using
@@ -2144,10 +2375,10 @@ to calculate event values can be found in that section.
 .PP
 Various ioctls act on
 .BR perf_event_open ()
-file descriptors
+file descriptors:
 .TP
 .B PERF_EVENT_IOC_ENABLE
-Enables the individual event or event group specified by the
+This enables the individual event or event group specified by the
 file descriptor argument.
 
 If the
@@ -2157,7 +2388,7 @@ enabled, even if the event specified is not the group leader
 (but see BUGS).
 .TP
 .B PERF_EVENT_IOC_DISABLE
-Disables the individual counter or event group specified by the
+This disables the individual counter or event group specified by the
 file descriptor argument.
 
 Enabling or disabling the leader of a group enables or disables the
@@ -2179,11 +2410,11 @@ to enable a counter for a number of overflows specified by the argument,
 after which it is disabled.
 Subsequent calls of this ioctl add the argument value to the current
 count.
-A signal with
+An overflow notification with
 .B POLL_IN
 set will happen on each overflow until the
-count reaches 0; when that happens a signal with
-POLL_HUP
+count reaches 0; when that happens a notification with
+.B POLL_HUP
 set is sent and the event is disabled.
 Using an argument of 0 is considered undefined behavior.
 .TP
@@ -2206,7 +2437,10 @@ reset, even if the event specified is not the group leader
 .B PERF_EVENT_IOC_PERIOD
 This updates the overflow period for the event.
 
-Since Linux 3.7 (on ARM) and Linux 3.14 (all other architectures),
+Since Linux 3.7 (on ARM)
+.\" commit 3581fe0ef37ce12ac7a4f74831168352ae848edc
+and Linux 3.14 (all other architectures),
+.\" commit bad7192b842c83e580747ca57104dd51fe08c223
 the new period takes effect immediately.
 On older kernels, the new period did not take effect until
 after the next overflow.
@@ -2214,7 +2448,9 @@ after the next overflow.
 The argument is a pointer to a 64-bit value containing the
 desired new period.
 
-Prior to Linux 2.6.36 this ioctl always failed due to a bug
+Prior to Linux 2.6.36
+.\" commit ad0cf3478de8677f720ee06393b3147819568d6a
+this ioctl always failed due to a bug
 in the kernel.
 
 .TP
@@ -2227,12 +2463,14 @@ The argument specifies the desired file descriptor, or \-1 if
 output should be ignored.
 .TP
 .BR PERF_EVENT_IOC_SET_FILTER " (since Linux 2.6.33)"
+.\" commit 6fb2915df7f0747d9044da9dbff5b46dc2e20830
 This adds an ftrace filter to this event.
 
 The argument is a pointer to the desired ftrace filter.
 .TP
 .BR PERF_EVENT_IOC_ID " (since Linux 3.12)"
-Returns the event ID value for the given event fd.
+.\" commit cf4957f17f2a89984915ea808876d9c82225b862
+This returns the event ID value for the given event file descriptor.
 
 The argument is a pointer to a 64-bit unsigned integer
 to hold the result.
@@ -2244,7 +2482,7 @@ attached to it using the
 and
 .B PR_TASK_PERF_EVENTS_DISABLE
 operations.
-This applies to all counters on the current process, whether created by
+This applies to all counters on the calling process, whether created by
 this process or by another, and does not affect any counters that this
 process has created on other processes.
 It enables or disables only
@@ -2261,7 +2499,7 @@ The
 file can be set to restrict access to the performance counters.
 .RS
 .IP 2 4
-only allow user-space measurements.
+allow only user-space measurements.
 .IP 1
 allow both kernel and user measurements (default).
 .IP 0
@@ -2286,34 +2524,42 @@ The default value is
 .TP
 .I /proc/sys/kernel/perf_event_mlock_kb
 
-Maximum number of pages an unprivileged user can mlock (2) .
+Maximum number of pages an unprivileged user can
+.BR mlock (2).
 The default is 516 (kB).
 
 .RE
 Files in
 .I /sys/bus/event_source/devices/
 .RS 4
-Since Linux 2.6.34 the kernel supports having multiple PMUs
+Since Linux 2.6.34, the kernel supports having multiple PMUs
 available for monitoring.
 Information on how to program these PMUs can be found under
 .IR /sys/bus/event_source/devices/ .
 Each subdirectory corresponds to a different PMU.
 .TP
 .IR /sys/bus/event_source/devices/*/type " (since Linux 2.6.38)"
+.\" commit abe43400579d5de0078c2d3a760e6598e183f871
 This contains an integer that can be used in the
 .I type
-field of perf_event_attr to indicate you wish to use this PMU.
+field of
+.I perf_event_attr
+to indicate that you wish to use this PMU.
 .TP
 .IR /sys/bus/event_source/devices/*/rdpmc " (since Linux 3.4)"
+.\" commit 0c9d42ed4cee2aa1dfc3a260b741baae8615744f
 If this file is 1, then direct user-space access to the
 performance counter registers is allowed via the rdpmc instruction.
 This can be disabled by echoing 0 to the file.
 .TP
 .IR /sys/bus/event_source/devices/*/format/ " (since Linux 3.4)"
+.\" commit 641cc938815dfd09f8fa1ec72deb814f0938ac33
 This subdirectory contains information on the architecture-specific
 subfields available for programming the various
 .I config
-fields in the perf_event_attr struct.
+fields in the
+.I perf_event_attr
+struct.
 
 The content of each file is the name of the config field, followed
 by a colon, followed by a series of integer bit ranges separated by
@@ -2323,9 +2569,11 @@ For example, the file
 may contain the value
 .I config1:1,6-10,44
 which indicates that event is an attribute that occupies bits 1,6-10, and 44
-of perf_event_attr::config1.
+of
+.IR perf_event_attr::config1 .
 .TP
 .IR /sys/bus/event_source/devices/*/events/ " (since Linux 3.4)"
+.\" commit 641cc938815dfd09f8fa1ec72deb814f0938ac33
 This subdirectory contains files with predefined events.
 The contents are strings describing the event settings
 expressed in terms of the fields found in the previously mentioned
@@ -2347,6 +2595,7 @@ This file is the standard kernel device interface
 for injecting hotplug events.
 .TP
 .IR /sys/bus/event_source/devices/*/cpumask " (since Linux 3.7)"
+.\" commit 314d9f63f385096580e9e2a06eaa0745d92fe4ac
 The
 .I cpumask
 file contains a comma-separated list of integers that
@@ -2362,9 +2611,14 @@ returns the new file descriptor, or \-1 if an error occurred
 .I errno
 is set appropriately).
 .SH ERRORS
+The errors returned by
+.BR perf_event_open ()
+can be inconsistent, and may
+vary across processor architectures and performance monitoring units.
 .TP
 .B E2BIG
-Returned if the perf_event_attr
+Returned if the
+.I perf_event_attr
 .I size
 value is too small
 (smaller than
@@ -2373,28 +2627,132 @@ too big (larger than the page size),
 or larger than the kernel supports and the extra bytes are not zero.
 When
 .B E2BIG
-is returned, the perf_event_attr
+is returned, the
+.I perf_event_attr
 .I size
 field is overwritten by the kernel to be the size of the structure
 it was expecting.
 .TP
+.B EACCES
+Returned when the requested event requires
+.B CAP_SYS_ADMIN
+permissions (or a more permissive perf_event paranoid setting).
+Some common cases where an unprivileged process
+may encounter this error:
+attaching to a process owned by a different user;
+monitoring all processes on a given CPU (i.e., specifying the
+.I pid
+argument as \-1);
+and not setting
+.I exclude_kernel
+when the paranoid setting requires it.
+.TP
+.B EBADF
+Returned if the
+.I group_fd
+file descriptor is not valid, or, if
+.B PERF_FLAG_PID_CGROUP
+is set,
+the cgroup file descriptor in
+.I pid
+is not valid.
+.TP
+.B EFAULT
+Returned if the
+.I attr
+pointer points at an invalid memory address.
+.TP
 .B EINVAL
-Returned if the specified event is not available.
+Returned if the specified event is invalid.
+There are many possible reasons for this.
+A not-exhaustive list:
+.I sample_freq
+is higher than the maximum setting;
+the
+.I cpu
+to monitor does not exist;
+.I read_format
+is out of range;
+.I sample_type
+is out of range;
+the
+.I flags
+value is out of range;
+.I exclusive
+or
+.I pinned
+set and the event is not a group leader;
+the event
+.I config
+values are out of range or set reserved bits;
+the generic event selected is not supported; or
+there is not enough room to add the selected event.
+.TP
+.B EMFILE
+Each opened event uses one file descriptor.
+If a large number of events are opened the per-user file
+descriptor limit (often 1024) will be hit and no more
+events can be created.
+.TP
+.B ENODEV
+Returned when the event involves a feature not supported
+by the current CPU.
+.TP
+.B ENOENT
+Returned if the
+.I type
+setting is not valid.
+This error is also returned for
+some unsupported generic events.
 .TP
 .B ENOSPC
 Prior to Linux 3.3, if there was not enough room for the event,
+.\" commit aa2bc1ade59003a379ffc485d6da2d92ea3370a6
 .B ENOSPC
 was returned.
-Linus did not like this, and this was changed to
+In Linux 3.3, this was changed to
 .BR EINVAL .
 .B ENOSPC
-is still returned if you try to read results into
-too small of a buffer.
+is still returned if you try to add more breakpoint events
+than supported by the hardware.
+.TP
+.B ENOSYS
+Returned if
+.B PERF_SAMPLE_STACK_USER
+is set in
+.I sample_type
+and it is not supported by hardware.
+.TP
+.B EOPNOTSUPP
+Returned if an event requiring a specific hardware feature is
+requested but there is no hardware support.
+This includes requesting low-skid events if not supported,
+branch tracing if it is not available, sampling if no PMU
+interrupt is available, and branch stacks for software events.
+.TP
+.B EPERM
+Returned on many (but not all) architectures when an unsupported
+.IR exclude_hv ", " exclude_idle ", " exclude_user ", or " exclude_kernel
+setting is specified.
+
+It can also happen, as with
+.BR EACCES ,
+when the requested event requires
+.B CAP_SYS_ADMIN
+permissions (or a more permissive perf_event paranoid setting).
+This includes setting a breakpoint on a kernel address,
+and (since Linux 3.13) setting a kernel function-trace tracepoint.
+.\" commit a4e95fc2cbb31d70a65beffeaf8773f881328c34
+.TP
+.B ESRCH
+Returned if attempting to attach to a process that does not exist.
 .SH VERSION
 .BR perf_event_open ()
 was introduced in Linux 2.6.31 but was called
+.\" commit 0793a61d4df8daeac6492dbf8d2f3e5713caae5e
 .BR perf_counter_open ().
 It was renamed in Linux 2.6.32.
+.\" commit cdd6c482c9ff9c55475ee7392ec8f672eddb7be6
 .SH CONFORMING TO
 This
 .BR perf_event_open ()
@@ -2417,8 +2775,11 @@ option to
 .BR fcntl (2)
 is needed to properly get overflow signals in threads.
 This was introduced in Linux 2.6.32.
+.\" commit ba0a6c9f6fceed11c6a99e8326f0477fe383e6b5
 
-Prior to Linux 2.6.33 (at least for x86) the kernel did not check
+Prior to Linux 2.6.33 (at least for x86),
+.\" commit b690081d4d3f6a23541493f1682835c3cd5c54a1
+the kernel did not check
 if events could be scheduled together until read time.
 The same happens on all known kernels if the NMI watchdog is enabled.
 This means to see if a given set of events works you have to
@@ -2426,17 +2787,21 @@ This means to see if a given set of events works you have to
 start, then read before you know for sure you
 can get valid measurements.
 
-Prior to Linux 2.6.34 event constraints were not enforced by the kernel.
+Prior to Linux 2.6.34, event constraints were not enforced by the kernel.
 In that case, some events would silently return "0" if the kernel
 scheduled them in an improper counter slot.
+.\" FIXME: cannot find a kernel commit for this one
 
-Prior to Linux 2.6.34 there was a bug when multiplexing where the
+Prior to Linux 2.6.34, there was a bug when multiplexing where the
 wrong results could be returned.
+.\" commit 45e16a6834b6af098702e5ea6c9a40de42ff77d8
 
 Kernels from Linux 2.6.35 to Linux 2.6.39 can quickly crash the kernel if
 "inherit" is enabled and many threads are started.
+.\" commit 38b435b16c36b0d863efcf3f07b34a6fac9873fd
 
 Prior to Linux 2.6.35,
+.\" commit 050735b08ca8a016bbace4445fa025b88fee770b
 .B PERF_FORMAT_GROUP
 did not work with attached processes.
 
@@ -2450,14 +2815,17 @@ Linux 2.6.36 and Linux 3.0 that ignores the
 "watermark" field and acts as if a wakeup_event
 was chosen if the union has a
 nonzero value in it.
+.\" commit 4ec8363dfc1451f8c8f86825731fe712798ada02
 
 From Linux 2.6.31 to Linux 3.4, the
 .B PERF_IOC_FLAG_GROUP
 ioctl argument was broken and would repeatedly operate
 on the event specified rather than iterating across
 all sibling events in a group.
+.\" commit 724b6daa13e100067c30cfc4d1ad06629609dc4e
 
 From Linux 3.4 to Linux 3.11, the mmap
+.\" commit fa7315871046b9a4c48627905691dbde57e51033
 .I cap_usr_rdpmc
 and
 .I cap_usr_time
@@ -2472,6 +2840,7 @@ Always double-check your results!
 Various generalized events have had wrong values.
 For example, retired branches measured
 the wrong thing on AMD machines until Linux 2.6.35.
+.\" commit f287d332ce835f77a4f5077d2c0ef1e3f9ea42d2
 .SH EXAMPLE
 The following is a short example that measures the total
 instruction count of a call to
@@ -2538,10 +2907,11 @@ main(int argc, char **argv)
 .BR prctl (2),
 .BR read (2)
 .SH COLOPHON
-This page is part of release 3.64 of the Linux
+This page is part of release 3.79 of the Linux
 .I man-pages
 project.
 A description of the project,
-and information about reporting bugs,
+information about reporting bugs,
+and the latest version of this page,
 can be found at
 \%http://www.kernel.org/doc/man\-pages/.