core.sys.linux.perf_event
D header file for perf_event_open system call.
Converted from linux userspace header, comments included.
Types 19
attr.type
Generalized performance event event_id types, used by the attr.event_id parameter of the sys_perf_event_open() syscall:
Generalized hardware cache events:
{ L1-D, L1-I, LLC, ITLB, DTLB, BPU, NODE } x { read, write, prefetch } x { accesses, misses }
Special "software" events provided by the kernel, even if the hardware does not support performance events. These events measure various physical and sw events of the kernel (and allow the profiling of them as well):
Bits that can be set in attr.sample_type to request information in the overflow packets.
values to program into branch_sample_type when PERF_SAMPLE_BRANCH is set
If the user does not pass priv level information via branch_sample_type, the kernel uses the event's priv level. Branch and event priv levels do not have to match. Branch priv level is checked for permissions.
The branch types can be combined, however BRANCH_ANY covers all types of branches and therefore it supersedes all the other types.
Values to determine ABI of the registers dump.
The format of the data returned by read() on a perf event fd, as specified by attr.read_format:
struct read_format {
{ u64 value;
{ u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED
{ u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING
{ u64 id; } && PERF_FORMAT_ID
} && !PERF_FORMAT_GROUP
{ u64 nr;
{ u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED
{ u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING
{ u64 value;
{ u64 id; } && PERF_FORMAT_ID
} cntr[nr];
} && PERF_FORMAT_GROUP
};Hardware event_id to monitor via a performance monitoring event:
@sample_max_stack: Max number of frame pointers in a callchain, should be < /proc/sys/kernel/perf_event_max_stack
uint typeMajor type: hardware/software/tracepoint/etc.uint sizeSize of the attr structure, for fwd/bwd compat.ulong configType specific configuration information.ulong sample_typeulong read_formatprivate ulong perf_event_attr_bitmanipulong disabled_minulong disabled_maxulong inherit_minulong inherit_maxulong pinned_minulong pinned_maxulong exclusive_minulong exclusive_maxulong exclude_user_minulong exclude_user_maxulong exclude_kernel_minulong exclude_kernel_maxulong exclude_hv_minulong exclude_hv_maxulong exclude_idle_minulong exclude_idle_maxulong mmap_minulong mmap_maxulong comm_minulong comm_maxulong freq_minulong freq_maxulong inherit_stat_minulong inherit_stat_maxulong enable_on_exec_minulong enable_on_exec_maxulong task_minulong task_maxulong watermark_minulong watermark_maxulong precise_ip_minulong precise_ip_maxulong mmap_data_minulong mmap_data_maxulong sample_id_all_minulong sample_id_all_maxulong exclude_host_minulong exclude_host_maxulong exclude_guest_minulong exclude_guest_maxulong exclude_callchain_kernel_minulong exclude_callchain_kernel_maxulong exclude_callchain_user_minulong exclude_callchain_user_maxulong mmap2_minulong mmap2_maxulong comm_exec_minulong comm_exec_maxulong use_clockid_minulong use_clockid_maxulong context_switch_minulong context_switch_maxulong write_backward_minulong write_backward_maxulong namespaces_minulong namespaces_maxulong __reserved_1_minulong __reserved_1_maxuint bp_typeulong branch_sample_typeulong sample_regs_userDefines set of user regs to dump on samples. See asm/perf_regs.h for details.uint sample_stack_userDefines size of the user stack to dump on samples.int clockidulong sample_regs_intrDefines set of regs to dump for each sample state captured on: - precise = 0: PMU interrupt - precise > 0: sampled instructionuint aux_watermarkWakeup watermark for AUX areaushort sample_max_stackushort __reserved_2align to __u64Structure of the page that can be mapped via mmap
uint version_uint compat_versionuint lockBits needed to read the hw events in user-space. --- u32 seq, timemult, timeshift, index, width; u64 count, enabled, running; u64 cyc, time_offset; s64 pmc = 0;uint indexlong offsetulong time_enabledulong time_runningushort pmc_widthIf capuserrdpmc this field provides the bit-width of the value read using the rdpmc() or equivalent instruction. This can be used to sign extend the result like:ushort time_shiftIf capusrtime the below fields can be used to compute the time delta since time_enabled (in ns) using rdtsc or similar.uint time_multulong time_offsetulong time_zeroIf capusrtime_zero, the hardware clock (e.g. TSC) can be calculated from sample timestamps.uint sizeubyte[948] __reservedHole for extension of the self monitor capabilitiesulong data_headControl data for the mmap() data buffer.ulong data_tailulong data_offsetulong data_sizeulong aux_headAUX area is defined by aux{offset,size} fields that should be set by the userspace, so that --- auxoffset >= dataoffset + datasize --- prior to mmap()ing it. Size of the mmap()ed area should be aux...ulong aux_tailulong aux_offsetulong aux_sizeuint typeushort miscushort sizeulong devulong inosingle taken branch record layout:
from: source instruction (may not always be a branch insn) to: branch target mispred: branch target was mispredicted predicted: branch target was predicted
support for mispred, predicted is optional. In case it is not supported mispred = predicted = 0.
in_tx: running in a hardware transaction abort: aborting a hardware transaction cycles: cycles from last branch (or 0 if not supported) type: branch type
ulong fromulong toprivate ulong perf_branch_entry_bitmanipulong mispred_minulong mispred_maxulong predicted_minulong predicted_maxulong in_tx_minulong in_tx_maxulong abort_minulong abort_maxulong cycles_minulong cycles_maxulong type_minulong type_maxulong reserved_minulong reserved_maxFunctions 2
long perf_event_open(perf_event_attr * hw_event, pid_t pid, int cpu, int group_fd, ulong flags)extern (D) auto perf_flags(T)(auto ref T attr)Variables 92
PERF_SAMPLE_BRANCH_PLM_ALL = perf_branch_sample_type.PERF_SAMPLE_BRANCH_USER
| perf_branch_sample_type.PERF_SAMPLE_BRANCH_KERNEL
| perf_branch_sample_type.PERF_SAMPLE_BRANCH_HVPERF_ATTR_SIZE_VER0 = 64sizeof first published struct
PERF_ATTR_SIZE_VER1 = 72add: config2
PERF_ATTR_SIZE_VER2 = 80add: branch_sample_type
PERF_ATTR_SIZE_VER3 = 96add: sample_regs_user
PERF_ATTR_SIZE_VER4 = 104add: sample_regs_intr
PERF_ATTR_SIZE_VER5 = 112add: aux_watermark
PERF_EVENT_IOC_ENABLE = _IO('$', 0)Ioctls that can be done on a perf event fd:
PERF_EVENT_IOC_DISABLE = _IO('$', 1)PERF_EVENT_IOC_REFRESH = _IO('$', 2)PERF_EVENT_IOC_RESET = _IO('$', 3)PERF_EVENT_IOC_PERIOD = _IOW!ulong('$', 4)PERF_EVENT_IOC_SET_OUTPUT = _IO('$', 5)PERF_EVENT_IOC_SET_FILTER = _IOW!(char *)('$', 6)PERF_EVENT_IOC_ID = _IOR!(ulong *)('$', 7)PERF_EVENT_IOC_SET_BPF = _IOW!uint('$', 8)PERF_EVENT_IOC_PAUSE_OUTPUT = _IOW!uint('$', 9)PERF_RECORD_MISC_CPUMODE_MASK = 7 << 0PERF_RECORD_MISC_CPUMODE_UNKNOWN = 0 << 0PERF_RECORD_MISC_KERNEL = 1 << 0PERF_RECORD_MISC_USER = 2 << 0PERF_RECORD_MISC_HYPERVISOR = 3 << 0PERF_RECORD_MISC_GUEST_KERNEL = 4 << 0PERF_RECORD_MISC_GUEST_USER = 5 << 0PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT = 1 << 12Indicates that /proc/PID/maps parsing are truncated by time out.
PERF_RECORD_MISC_MMAP_DATA = 1 << 13PERF_RECORD_MISC_MMAP_DATA and PERF_RECORD_MISC_COMM_EXEC are used on different events so can reuse the same bit position. Ditto PERF_RECORD_MISC_SWITCH_OUT.
PERF_RECORD_MISC_COMM_EXEC = 1 << 13PERF_RECORD_MISC_SWITCH_OUT = 1 << 13PERF_RECORD_MISC_EXACT_IP = 1 << 14Indicates that the content of PERF_SAMPLE_IP points to the actual instruction that triggered the event. See also perf_event_attr::precise_ip.
PERF_RECORD_MISC_EXT_RESERVED = 1 << 15Reserve the last bit to indicate some extended misc field
PERF_MAX_STACK_DEPTH = 127PERF_MAX_CONTEXTS_PER_STACK = 8PERF_AUX_FLAG_TRUNCATED = 0x01PERF_RECORD_AUX::flags bits record was truncated to fit
PERF_AUX_FLAG_OVERWRITE = 0x02snapshot from overwrite mode
PERF_AUX_FLAG_PARTIAL = 0x04record contains gaps
PERF_AUX_FLAG_COLLISION = 0x08sample collided with another
PERF_FLAG_FD_NO_GROUP = 1UL << 0PERF_FLAG_FD_OUTPUT = 1UL << 1PERF_FLAG_PID_CGROUP = 1UL << 2pid=cgroup id, per-cpu mode only
PERF_FLAG_FD_CLOEXEC = 1UL << 3O_CLOEXEC
PERF_MEM_OP_NA = 0x01type of opcode (load/store/prefetch,code) not available
PERF_MEM_OP_LOAD = 0x02load instruction
PERF_MEM_OP_STORE = 0x04store instruction
PERF_MEM_OP_PFETCH = 0x08prefetch
PERF_MEM_OP_EXEC = 0x10code (execution)
PERF_MEM_OP_SHIFT = 0PERF_MEM_LVL_NA = 0x01not available
PERF_MEM_LVL_HIT = 0x02hit level
PERF_MEM_LVL_MISS = 0x04miss level
PERF_MEM_LVL_L1 = 0x08L1
PERF_MEM_LVL_LFB = 0x10Line Fill Buffer
PERF_MEM_LVL_L2 = 0x20L2
PERF_MEM_LVL_L3 = 0x40L3
PERF_MEM_LVL_LOC_RAM = 0x80Local DRAM
PERF_MEM_LVL_REM_RAM1 = 0x100Remote DRAM (1 hop)
PERF_MEM_LVL_REM_RAM2 = 0x200Remote DRAM (2 hops)
PERF_MEM_LVL_REM_CCE1 = 0x400Remote Cache (1 hop)
PERF_MEM_LVL_REM_CCE2 = 0x800Remote Cache (2 hops)
PERF_MEM_LVL_IO = 0x1000I/O memory
PERF_MEM_LVL_UNC = 0x2000Uncached memory
PERF_MEM_LVL_SHIFT = 5PERF_MEM_REMOTE_REMOTE = 0x01Remote
PERF_MEM_REMOTE_SHIFT = 37PERF_MEM_LVLNUM_L1 = 0x01L1
PERF_MEM_LVLNUM_L2 = 0x02L2
PERF_MEM_LVLNUM_L3 = 0x03L3
PERF_MEM_LVLNUM_L4 = 0x04L4
PERF_MEM_LVLNUM_ANY_CACHE = 0x0bAny cache
PERF_MEM_LVLNUM_LFB = 0x0cLFB
PERF_MEM_LVLNUM_RAM = 0x0dRAM
PERF_MEM_LVLNUM_PMEM = 0x0ePMEM
PERF_MEM_LVLNUM_NA = 0x0fN/A
PERF_MEM_LVLNUM_SHIFT = 33PERF_MEM_SNOOP_NA = 0x01not available
PERF_MEM_SNOOP_NONE = 0x02no snoop
PERF_MEM_SNOOP_HIT = 0x04snoop hit
PERF_MEM_SNOOP_MISS = 0x08snoop miss
PERF_MEM_SNOOP_HITM = 0x10snoop hit modified
PERF_MEM_SNOOP_SHIFT = 19PERF_MEM_SNOOPX_FWD = 0x01forward
PERF_MEM_SNOOPX_SHIFT = 371 free
PERF_MEM_LOCK_NA = 0x01locked instruction not available
PERF_MEM_LOCK_LOCKED = 0x02locked transaction
PERF_MEM_LOCK_SHIFT = 24PERF_MEM_TLB_NA = 0x01not available
PERF_MEM_TLB_HIT = 0x02hit level
PERF_MEM_TLB_MISS = 0x04miss level
PERF_MEM_TLB_L1 = 0x08L1
PERF_MEM_TLB_L2 = 0x10L2
PERF_MEM_TLB_WK = 0x20Hardware Walker
PERF_MEM_TLB_OS = 0x40OS fault handler
PERF_MEM_TLB_SHIFT = 26