core.sys.linux.perf_event

D header file for perf_event_open system call.

Converted from linux userspace header, comments included.

Authors

Max Haughton
var PERF_ATTR_SIZE_VER0 PERF_ATTR_SIZE_VER1 PERF_ATTR_SIZE_VER2 PERF_ATTR_SIZE_VER3 PERF_ATTR_SIZE_VER4 PERF_ATTR_SIZE_VER5 PERF_AUX_FLAG_COLLISION PERF_AUX_FLAG_OVERWRITE PERF_AUX_FLAG_PARTIAL PERF_AUX_FLAG_TRUNCATED PERF_EVENT_IOC_DISABLE PERF_EVENT_IOC_ENABLE PERF_EVENT_IOC_ID PERF_EVENT_IOC_PAUSE_OUTPUT PERF_EVENT_IOC_PERIOD PERF_EVENT_IOC_REFRESH PERF_EVENT_IOC_RESET PERF_EVENT_IOC_SET_BPF PERF_EVENT_IOC_SET_FILTER PERF_EVENT_IOC_SET_OUTPUT PERF_FLAG_FD_CLOEXEC PERF_FLAG_FD_NO_GROUP PERF_FLAG_FD_OUTPUT PERF_FLAG_PID_CGROUP PERF_MAX_CONTEXTS_PER_STACK PERF_MAX_STACK_DEPTH PERF_MEM_LOCK_LOCKED PERF_MEM_LOCK_NA PERF_MEM_LOCK_SHIFT PERF_MEM_LVL_HIT PERF_MEM_LVL_IO PERF_MEM_LVL_L1 PERF_MEM_LVL_L2 PERF_MEM_LVL_L3 PERF_MEM_LVL_LFB PERF_MEM_LVL_LOC_RAM PERF_MEM_LVL_MISS PERF_MEM_LVL_NA PERF_MEM_LVL_REM_CCE1 PERF_MEM_LVL_REM_CCE2 PERF_MEM_LVL_REM_RAM1 PERF_MEM_LVL_REM_RAM2 PERF_MEM_LVL_SHIFT PERF_MEM_LVL_UNC PERF_MEM_LVLNUM_ANY_CACHE PERF_MEM_LVLNUM_L1 PERF_MEM_LVLNUM_L2 PERF_MEM_LVLNUM_L3 PERF_MEM_LVLNUM_L4 PERF_MEM_LVLNUM_LFB PERF_MEM_LVLNUM_NA PERF_MEM_LVLNUM_PMEM PERF_MEM_LVLNUM_RAM PERF_MEM_LVLNUM_SHIFT PERF_MEM_OP_EXEC PERF_MEM_OP_LOAD PERF_MEM_OP_NA PERF_MEM_OP_PFETCH PERF_MEM_OP_SHIFT PERF_MEM_OP_STORE PERF_MEM_REMOTE_REMOTE PERF_MEM_REMOTE_SHIFT PERF_MEM_SNOOP_HIT PERF_MEM_SNOOP_HITM PERF_MEM_SNOOP_MISS PERF_MEM_SNOOP_NA PERF_MEM_SNOOP_NONE PERF_MEM_SNOOP_SHIFT PERF_MEM_SNOOPX_FWD PERF_MEM_SNOOPX_SHIFT PERF_MEM_TLB_HIT PERF_MEM_TLB_L1 PERF_MEM_TLB_L2 PERF_MEM_TLB_MISS PERF_MEM_TLB_NA PERF_MEM_TLB_OS PERF_MEM_TLB_SHIFT PERF_MEM_TLB_WK PERF_RECORD_MISC_COMM_EXEC PERF_RECORD_MISC_CPUMODE_MASK PERF_RECORD_MISC_CPUMODE_UNKNOWN PERF_RECORD_MISC_EXACT_IP PERF_RECORD_MISC_EXT_RESERVED PERF_RECORD_MISC_GUEST_KERNEL PERF_RECORD_MISC_GUEST_USER PERF_RECORD_MISC_HYPERVISOR PERF_RECORD_MISC_KERNEL PERF_RECORD_MISC_MMAP_DATA PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT PERF_RECORD_MISC_SWITCH_OUT PERF_RECORD_MISC_USER PERF_SAMPLE_BRANCH_PLM_ALL

Types 19

enumperf_type_id

attr.type

PERF_TYPE_HARDWARE = 0
PERF_TYPE_SOFTWARE = 1
PERF_TYPE_TRACEPOINT = 2
PERF_TYPE_HW_CACHE = 3
PERF_TYPE_RAW = 4
PERF_TYPE_BREAKPOINT = 5
PERF_TYPE_MAX = 6
enumperf_hw_id

Generalized performance event event_id types, used by the attr.event_id parameter of the sys_perf_event_open() syscall:

PERF_COUNT_HW_CPU_CYCLES = 0
PERF_COUNT_HW_INSTRUCTIONS = 1
PERF_COUNT_HW_CACHE_REFERENCES = 2
PERF_COUNT_HW_CACHE_MISSES = 3
PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4
PERF_COUNT_HW_BRANCH_MISSES = 5
PERF_COUNT_HW_BUS_CYCLES = 6
PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7
PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8
PERF_COUNT_HW_REF_CPU_CYCLES = 9
PERF_COUNT_HW_MAX = 10
enumperf_hw_cache_id

Generalized hardware cache events:

{ L1-D, L1-I, LLC, ITLB, DTLB, BPU, NODE } x { read, write, prefetch } x { accesses, misses }

PERF_COUNT_HW_CACHE_L1D = 0
PERF_COUNT_HW_CACHE_L1I = 1
PERF_COUNT_HW_CACHE_LL = 2
PERF_COUNT_HW_CACHE_DTLB = 3
PERF_COUNT_HW_CACHE_ITLB = 4
PERF_COUNT_HW_CACHE_BPU = 5
PERF_COUNT_HW_CACHE_NODE = 6
PERF_COUNT_HW_CACHE_MAX = 7
enumperf_hw_cache_op_id
PERF_COUNT_HW_CACHE_OP_READ = 0
PERF_COUNT_HW_CACHE_OP_WRITE = 1
PERF_COUNT_HW_CACHE_OP_PREFETCH = 2
PERF_COUNT_HW_CACHE_OP_MAX = 3
enumperf_hw_cache_op_result_id
PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0
PERF_COUNT_HW_CACHE_RESULT_MISS = 1
PERF_COUNT_HW_CACHE_RESULT_MAX = 2
enumperf_sw_ids

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):

PERF_COUNT_SW_CPU_CLOCK = 0
PERF_COUNT_SW_TASK_CLOCK = 1
PERF_COUNT_SW_PAGE_FAULTS = 2
PERF_COUNT_SW_CONTEXT_SWITCHES = 3
PERF_COUNT_SW_CPU_MIGRATIONS = 4
PERF_COUNT_SW_PAGE_FAULTS_MIN = 5
PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6
PERF_COUNT_SW_ALIGNMENT_FAULTS = 7
PERF_COUNT_SW_EMULATION_FAULTS = 8
PERF_COUNT_SW_DUMMY = 9
PERF_COUNT_SW_BPF_OUTPUT = 10
PERF_COUNT_SW_MAX = 11
enumperf_event_sample_format

Bits that can be set in attr.sample_type to request information in the overflow packets.

PERF_SAMPLE_IP = 1U << 0
PERF_SAMPLE_TID = 1U << 1
PERF_SAMPLE_TIME = 1U << 2
PERF_SAMPLE_ADDR = 1U << 3
PERF_SAMPLE_READ = 1U << 4
PERF_SAMPLE_CALLCHAIN = 1U << 5
PERF_SAMPLE_ID = 1U << 6
PERF_SAMPLE_CPU = 1U << 7
PERF_SAMPLE_PERIOD = 1U << 8
PERF_SAMPLE_STREAM_ID = 1U << 9
PERF_SAMPLE_RAW = 1U << 10
PERF_SAMPLE_BRANCH_STACK = 1U << 11
PERF_SAMPLE_REGS_USER = 1U << 12
PERF_SAMPLE_STACK_USER = 1U << 13
PERF_SAMPLE_WEIGHT = 1U << 14
PERF_SAMPLE_DATA_SRC = 1U << 15
PERF_SAMPLE_IDENTIFIER = 1U << 16
PERF_SAMPLE_TRANSACTION = 1U << 17
PERF_SAMPLE_REGS_INTR = 1U << 18
PERF_SAMPLE_PHYS_ADDR = 1U << 19
PERF_SAMPLE_MAX = 1U << 20
enumperf_branch_sample_type_shift

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.

PERF_SAMPLE_BRANCH_USER_SHIFT = 0user branches
PERF_SAMPLE_BRANCH_KERNEL_SHIFT = 1kernel branches
PERF_SAMPLE_BRANCH_HV_SHIFT = 2hypervisor branches
PERF_SAMPLE_BRANCH_ANY_SHIFT = 3any branch types
PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT = 4any call branch
PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT = 5any return branch
PERF_SAMPLE_BRANCH_IND_CALL_SHIFT = 6indirect calls
PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT = 7transaction aborts
PERF_SAMPLE_BRANCH_IN_TX_SHIFT = 8in transaction
PERF_SAMPLE_BRANCH_NO_TX_SHIFT = 9not in transaction
PERF_SAMPLE_BRANCH_COND_SHIFT = 10conditional branches
PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT = 11call/ret stack
PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT = 12indirect jumps
PERF_SAMPLE_BRANCH_CALL_SHIFT = 13direct call
PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT = 14no flags
PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 15no cycles
PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 16save branch type
PERF_SAMPLE_BRANCH_MAX_SHIFT = 17non-ABI
enumperf_branch_sample_type
PERF_SAMPLE_BRANCH_USER = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_USER_SHIFT
PERF_SAMPLE_BRANCH_KERNEL = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_KERNEL_SHIFT
PERF_SAMPLE_BRANCH_HV = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_HV_SHIFT
PERF_SAMPLE_BRANCH_ANY = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_ANY_SHIFT
PERF_SAMPLE_BRANCH_ANY_CALL = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT
PERF_SAMPLE_BRANCH_ANY_RETURN = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT
PERF_SAMPLE_BRANCH_IND_CALL = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_IND_CALL_SHIFT
PERF_SAMPLE_BRANCH_ABORT_TX = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT
PERF_SAMPLE_BRANCH_IN_TX = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_IN_TX_SHIFT
PERF_SAMPLE_BRANCH_NO_TX = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_NO_TX_SHIFT
PERF_SAMPLE_BRANCH_COND = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_COND_SHIFT
PERF_SAMPLE_BRANCH_CALL_STACK = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT
PERF_SAMPLE_BRANCH_IND_JUMP = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT
PERF_SAMPLE_BRANCH_CALL = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_CALL_SHIFT
PERF_SAMPLE_BRANCH_NO_FLAGS = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT
PERF_SAMPLE_BRANCH_NO_CYCLES = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT
PERF_SAMPLE_BRANCH_TYPE_SAVE = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT
PERF_SAMPLE_BRANCH_MAX = 1U << perf_branch_sample_type_shift.PERF_SAMPLE_BRANCH_MAX_SHIFT
enumperf_sample_regs_abi

Values to determine ABI of the registers dump.

PERF_SAMPLE_REGS_ABI_NONE = 0
PERF_SAMPLE_REGS_ABI_32 = 1
PERF_SAMPLE_REGS_ABI_64 = 2
enumperf_event_read_format

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
};

PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0
PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1
PERF_FORMAT_ID = 1U << 2
PERF_FORMAT_GROUP = 1U << 3
PERF_FORMAT_MAX = 1U << 4non-ABI
structperf_event_attr

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

Fields
uint typeMajor type: hardware/software/tracepoint/etc.
uint sizeSize of the attr structure, for fwd/bwd compat.
ulong configType specific configuration information.
ulong sample_type
ulong read_format
private ulong perf_event_attr_bitmanip
ulong disabled_min
ulong disabled_max
ulong inherit_min
ulong inherit_max
ulong pinned_min
ulong pinned_max
ulong exclusive_min
ulong exclusive_max
ulong exclude_user_min
ulong exclude_user_max
ulong exclude_kernel_min
ulong exclude_kernel_max
ulong exclude_hv_min
ulong exclude_hv_max
ulong exclude_idle_min
ulong exclude_idle_max
ulong mmap_min
ulong mmap_max
ulong comm_min
ulong comm_max
ulong freq_min
ulong freq_max
ulong inherit_stat_min
ulong inherit_stat_max
ulong enable_on_exec_min
ulong enable_on_exec_max
ulong task_min
ulong task_max
ulong watermark_min
ulong watermark_max
ulong precise_ip_min
ulong precise_ip_max
ulong mmap_data_min
ulong mmap_data_max
ulong sample_id_all_min
ulong sample_id_all_max
ulong exclude_host_min
ulong exclude_host_max
ulong exclude_guest_min
ulong exclude_guest_max
ulong exclude_callchain_kernel_min
ulong exclude_callchain_kernel_max
ulong exclude_callchain_user_min
ulong exclude_callchain_user_max
ulong mmap2_min
ulong mmap2_max
ulong comm_exec_min
ulong comm_exec_max
ulong use_clockid_min
ulong use_clockid_max
ulong context_switch_min
ulong context_switch_max
ulong write_backward_min
ulong write_backward_max
ulong namespaces_min
ulong namespaces_max
ulong __reserved_1_min
ulong __reserved_1_max
uint bp_type
ulong branch_sample_type
ulong 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 clockid
ulong sample_regs_intrDefines set of regs to dump for each sample state captured on: - precise = 0: PMU interrupt - precise > 0: sampled instruction
uint aux_watermarkWakeup watermark for AUX area
ushort sample_max_stack
ushort __reserved_2align to __u64
Methods
ulong disabled() @property @safe pure nothrow @nogc const
void disabled(ulong v) @property @safe pure nothrow @nogc
ulong inherit() @property @safe pure nothrow @nogc const
void inherit(ulong v) @property @safe pure nothrow @nogc
ulong pinned() @property @safe pure nothrow @nogc const
void pinned(ulong v) @property @safe pure nothrow @nogc
ulong exclusive() @property @safe pure nothrow @nogc const
void exclusive(ulong v) @property @safe pure nothrow @nogc
ulong exclude_user() @property @safe pure nothrow @nogc const
void exclude_user(ulong v) @property @safe pure nothrow @nogc
ulong exclude_kernel() @property @safe pure nothrow @nogc const
void exclude_kernel(ulong v) @property @safe pure nothrow @nogc
ulong exclude_hv() @property @safe pure nothrow @nogc const
void exclude_hv(ulong v) @property @safe pure nothrow @nogc
ulong exclude_idle() @property @safe pure nothrow @nogc const
void exclude_idle(ulong v) @property @safe pure nothrow @nogc
ulong mmap() @property @safe pure nothrow @nogc const
void mmap(ulong v) @property @safe pure nothrow @nogc
ulong comm() @property @safe pure nothrow @nogc const
void comm(ulong v) @property @safe pure nothrow @nogc
ulong freq() @property @safe pure nothrow @nogc const
void freq(ulong v) @property @safe pure nothrow @nogc
ulong inherit_stat() @property @safe pure nothrow @nogc const
void inherit_stat(ulong v) @property @safe pure nothrow @nogc
ulong enable_on_exec() @property @safe pure nothrow @nogc const
void enable_on_exec(ulong v) @property @safe pure nothrow @nogc
ulong task() @property @safe pure nothrow @nogc const
void task(ulong v) @property @safe pure nothrow @nogc
ulong watermark() @property @safe pure nothrow @nogc const
void watermark(ulong v) @property @safe pure nothrow @nogc
ulong precise_ip() @property @safe pure nothrow @nogc const
void precise_ip(ulong v) @property @safe pure nothrow @nogc
ulong mmap_data() @property @safe pure nothrow @nogc const
void mmap_data(ulong v) @property @safe pure nothrow @nogc
ulong sample_id_all() @property @safe pure nothrow @nogc const
void sample_id_all(ulong v) @property @safe pure nothrow @nogc
ulong exclude_host() @property @safe pure nothrow @nogc const
void exclude_host(ulong v) @property @safe pure nothrow @nogc
ulong exclude_guest() @property @safe pure nothrow @nogc const
void exclude_guest(ulong v) @property @safe pure nothrow @nogc
ulong exclude_callchain_kernel() @property @safe pure nothrow @nogc const
void exclude_callchain_kernel(ulong v) @property @safe pure nothrow @nogc
ulong exclude_callchain_user() @property @safe pure nothrow @nogc const
void exclude_callchain_user(ulong v) @property @safe pure nothrow @nogc
ulong mmap2() @property @safe pure nothrow @nogc const
void mmap2(ulong v) @property @safe pure nothrow @nogc
ulong comm_exec() @property @safe pure nothrow @nogc const
void comm_exec(ulong v) @property @safe pure nothrow @nogc
ulong use_clockid() @property @safe pure nothrow @nogc const
void use_clockid(ulong v) @property @safe pure nothrow @nogc
ulong context_switch() @property @safe pure nothrow @nogc const
void context_switch(ulong v) @property @safe pure nothrow @nogc
ulong write_backward() @property @safe pure nothrow @nogc const
void write_backward(ulong v) @property @safe pure nothrow @nogc
ulong namespaces() @property @safe pure nothrow @nogc const
void namespaces(ulong v) @property @safe pure nothrow @nogc
ulong __reserved_1() @property @safe pure nothrow @nogc const
void __reserved_1(ulong v) @property @safe pure nothrow @nogc
enumperf_event_ioc_flags
PERF_IOC_FLAG_GROUP = 1U << 0
structperf_event_mmap_page

Structure of the page that can be mapped via mmap

Fields
uint version_
uint compat_version
uint 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 index
long offset
ulong time_enabled
ulong time_running
ushort 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_mult
ulong time_offset
ulong time_zeroIf capusrtime_zero, the hardware clock (e.g. TSC) can be calculated from sample timestamps.
uint size
ubyte[948] __reservedHole for extension of the self monitor capabilities
ulong data_headControl data for the mmap() data buffer.
ulong data_tail
ulong data_offset
ulong data_size
ulong 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_tail
ulong aux_offset
ulong aux_size
structperf_event_header
Fields
uint type
ushort misc
ushort size
structperf_ns_link_info
Fields
ulong dev
ulong ino
enumperf_event_type
PERF_RECORD_MMAP = 1If perfeventattr.sampleidall is set then all event types will have the sampletype selected fields related to where/when (identity) an event took place (TID, TIME, ID, STREAMID, CPU, IDENTIFIER) des...
PERF_RECORD_LOST = 2--- struct { struct perfeventheader header; u64 id; u64 lost; struct sampleid sampleid; }; ---
PERF_RECORD_COMM = 3--- struct { struct perfeventheader header;
PERF_RECORD_EXIT = 4--- struct { struct perfeventheader header; u32 pid, ppid; u32 tid, ptid; u64 time; struct sampleid sampleid; }; ---
PERF_RECORD_THROTTLE = 5--- struct { struct perfeventheader header; u64 time; u64 id; u64 streamid; struct sampleid sample_id; }; ---
PERF_RECORD_UNTHROTTLE = 6
PERF_RECORD_FORK = 7--- struct { struct perfeventheader header; u32 pid, ppid; u32 tid, ptid; u64 time; struct sampleid sampleid; }; ---
PERF_RECORD_READ = 8--- struct { struct perfeventheader header; u32 pid, tid;
PERF_RECORD_SAMPLE = 9--- struct { struct perfeventheader header;
PERF_RECORD_MMAP2 = 10--- The MMAP2 records are an augmented version of MMAP, they add maj, min, ino numbers to be used to uniquely identify each mapping
PERF_RECORD_AUX = 11Records that new data landed in the AUX buffer part. --- struct { struct perfeventheader header;
PERF_RECORD_ITRACE_START = 12--- Indicates that instruction trace has started
PERF_RECORD_LOST_SAMPLES = 13Records the dropped/lost sample number. --- struct { struct perfeventheader header;
PERF_RECORD_SWITCH = 14Records a context switch in or out (flagged by PERFRECORDMISCSWITCHOUT). See also PERFRECORDSWITCHCPUWIDE. --- struct { struct perfeventheader header; struct sampleid sampleid; }; ---
PERF_RECORD_SWITCH_CPU_WIDE = 15CPU-wide version of PERFRECORDSWITCH with nextprevpid and nextprevtid that are the next (switching out) or previous (switching in) pid/tid. --- struct { struct perfeventheader header; u32 ...
PERF_RECORD_NAMESPACES = 16--- struct { struct perfeventheader header; u32 pid; u32 tid; u64 nrnamespaces; { u64 dev, inode; } [nrnamespaces]; struct sampleid ...
PERF_RECORD_MAX = 17
enumperf_callchain_context
PERF_CONTEXT_HV = cast(ulong) - 32
PERF_CONTEXT_KERNEL = cast(ulong) - 128
PERF_CONTEXT_USER = cast(ulong) - 512
PERF_CONTEXT_GUEST = cast(ulong) - 2048
PERF_CONTEXT_GUEST_KERNEL = cast(ulong) - 2176
PERF_CONTEXT_GUEST_USER = cast(ulong) - 2560
PERF_CONTEXT_MAX = cast(ulong) - 4095
structperf_branch_entry

single 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

Fields
ulong from
ulong to
private ulong perf_branch_entry_bitmanip
ulong mispred_min
ulong mispred_max
ulong predicted_min
ulong predicted_max
ulong in_tx_min
ulong in_tx_max
ulong abort_min
ulong abort_max
ulong cycles_min
ulong cycles_max
ulong type_min
ulong type_max
ulong reserved_min
ulong reserved_max
Methods
ulong mispred() @property @safe pure nothrow @nogc const
void mispred(ulong v) @property @safe pure nothrow @nogc
ulong predicted() @property @safe pure nothrow @nogc const
void predicted(ulong v) @property @safe pure nothrow @nogc
ulong in_tx() @property @safe pure nothrow @nogc const
void in_tx(ulong v) @property @safe pure nothrow @nogc
ulong abort() @property @safe pure nothrow @nogc const
void abort(ulong v) @property @safe pure nothrow @nogc
ulong cycles() @property @safe pure nothrow @nogc const
void cycles(ulong v) @property @safe pure nothrow @nogc
ulong type() @property @safe pure nothrow @nogc const
void type(ulong v) @property @safe pure nothrow @nogc
ulong reserved() @property @safe pure nothrow @nogc const
void reserved(ulong v) @property @safe pure nothrow @nogc

Functions 2

fnlong perf_event_open(perf_event_attr * hw_event, pid_t pid, int cpu, int group_fd, ulong flags)
fnextern (D) auto perf_flags(T)(auto ref T attr)

Variables 92

enumvarPERF_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_HV
enumvarPERF_ATTR_SIZE_VER0 = 64

sizeof first published struct

enumvarPERF_ATTR_SIZE_VER1 = 72

add: config2

enumvarPERF_ATTR_SIZE_VER2 = 80

add: branch_sample_type

enumvarPERF_ATTR_SIZE_VER3 = 96

add: sample_regs_user

enumvarPERF_ATTR_SIZE_VER4 = 104

add: sample_regs_intr

enumvarPERF_ATTR_SIZE_VER5 = 112

add: aux_watermark

enumvarPERF_EVENT_IOC_ENABLE = _IO('$', 0)

Ioctls that can be done on a perf event fd:

enumvarPERF_EVENT_IOC_DISABLE = _IO('$', 1)
enumvarPERF_EVENT_IOC_REFRESH = _IO('$', 2)
enumvarPERF_EVENT_IOC_RESET = _IO('$', 3)
enumvarPERF_EVENT_IOC_PERIOD = _IOW!ulong('$', 4)
enumvarPERF_EVENT_IOC_SET_OUTPUT = _IO('$', 5)
enumvarPERF_EVENT_IOC_SET_FILTER = _IOW!(char *)('$', 6)
enumvarPERF_EVENT_IOC_ID = _IOR!(ulong *)('$', 7)
enumvarPERF_EVENT_IOC_SET_BPF = _IOW!uint('$', 8)
enumvarPERF_EVENT_IOC_PAUSE_OUTPUT = _IOW!uint('$', 9)
enumvarPERF_RECORD_MISC_CPUMODE_MASK = 7 << 0
enumvarPERF_RECORD_MISC_CPUMODE_UNKNOWN = 0 << 0
enumvarPERF_RECORD_MISC_KERNEL = 1 << 0
enumvarPERF_RECORD_MISC_USER = 2 << 0
enumvarPERF_RECORD_MISC_HYPERVISOR = 3 << 0
enumvarPERF_RECORD_MISC_GUEST_KERNEL = 4 << 0
enumvarPERF_RECORD_MISC_GUEST_USER = 5 << 0
enumvarPERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT = 1 << 12

Indicates that /proc/PID/maps parsing are truncated by time out.

enumvarPERF_RECORD_MISC_MMAP_DATA = 1 << 13

PERF_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.

enumvarPERF_RECORD_MISC_COMM_EXEC = 1 << 13
enumvarPERF_RECORD_MISC_SWITCH_OUT = 1 << 13
enumvarPERF_RECORD_MISC_EXACT_IP = 1 << 14

Indicates that the content of PERF_SAMPLE_IP points to the actual instruction that triggered the event. See also perf_event_attr::precise_ip.

enumvarPERF_RECORD_MISC_EXT_RESERVED = 1 << 15

Reserve the last bit to indicate some extended misc field

enumvarPERF_MAX_STACK_DEPTH = 127
enumvarPERF_MAX_CONTEXTS_PER_STACK = 8
enumvarPERF_AUX_FLAG_TRUNCATED = 0x01

PERF_RECORD_AUX::flags bits record was truncated to fit

enumvarPERF_AUX_FLAG_OVERWRITE = 0x02

snapshot from overwrite mode

enumvarPERF_AUX_FLAG_PARTIAL = 0x04

record contains gaps

enumvarPERF_AUX_FLAG_COLLISION = 0x08

sample collided with another

enumvarPERF_FLAG_FD_NO_GROUP = 1UL << 0
enumvarPERF_FLAG_FD_OUTPUT = 1UL << 1
enumvarPERF_FLAG_PID_CGROUP = 1UL << 2

pid=cgroup id, per-cpu mode only

enumvarPERF_FLAG_FD_CLOEXEC = 1UL << 3

O_CLOEXEC

enumvarPERF_MEM_OP_NA = 0x01

type of opcode (load/store/prefetch,code) not available

enumvarPERF_MEM_OP_LOAD = 0x02

load instruction

enumvarPERF_MEM_OP_STORE = 0x04

store instruction

enumvarPERF_MEM_OP_PFETCH = 0x08

prefetch

enumvarPERF_MEM_OP_EXEC = 0x10

code (execution)

enumvarPERF_MEM_OP_SHIFT = 0
enumvarPERF_MEM_LVL_NA = 0x01

not available

enumvarPERF_MEM_LVL_HIT = 0x02

hit level

enumvarPERF_MEM_LVL_MISS = 0x04

miss level

enumvarPERF_MEM_LVL_L1 = 0x08

L1

enumvarPERF_MEM_LVL_LFB = 0x10

Line Fill Buffer

enumvarPERF_MEM_LVL_L2 = 0x20

L2

enumvarPERF_MEM_LVL_L3 = 0x40

L3

enumvarPERF_MEM_LVL_LOC_RAM = 0x80

Local DRAM

enumvarPERF_MEM_LVL_REM_RAM1 = 0x100

Remote DRAM (1 hop)

enumvarPERF_MEM_LVL_REM_RAM2 = 0x200

Remote DRAM (2 hops)

enumvarPERF_MEM_LVL_REM_CCE1 = 0x400

Remote Cache (1 hop)

enumvarPERF_MEM_LVL_REM_CCE2 = 0x800

Remote Cache (2 hops)

enumvarPERF_MEM_LVL_IO = 0x1000

I/O memory

enumvarPERF_MEM_LVL_UNC = 0x2000

Uncached memory

enumvarPERF_MEM_LVL_SHIFT = 5
enumvarPERF_MEM_REMOTE_REMOTE = 0x01

Remote

enumvarPERF_MEM_REMOTE_SHIFT = 37
enumvarPERF_MEM_LVLNUM_L1 = 0x01

L1

enumvarPERF_MEM_LVLNUM_L2 = 0x02

L2

enumvarPERF_MEM_LVLNUM_L3 = 0x03

L3

enumvarPERF_MEM_LVLNUM_L4 = 0x04

L4

enumvarPERF_MEM_LVLNUM_ANY_CACHE = 0x0b

Any cache

enumvarPERF_MEM_LVLNUM_LFB = 0x0c

LFB

enumvarPERF_MEM_LVLNUM_RAM = 0x0d

RAM

enumvarPERF_MEM_LVLNUM_PMEM = 0x0e

PMEM

enumvarPERF_MEM_LVLNUM_NA = 0x0f

N/A

enumvarPERF_MEM_LVLNUM_SHIFT = 33
enumvarPERF_MEM_SNOOP_NA = 0x01

not available

enumvarPERF_MEM_SNOOP_NONE = 0x02

no snoop

enumvarPERF_MEM_SNOOP_HIT = 0x04

snoop hit

enumvarPERF_MEM_SNOOP_MISS = 0x08

snoop miss

enumvarPERF_MEM_SNOOP_HITM = 0x10

snoop hit modified

enumvarPERF_MEM_SNOOP_SHIFT = 19
enumvarPERF_MEM_SNOOPX_FWD = 0x01

forward

enumvarPERF_MEM_SNOOPX_SHIFT = 37

1 free

enumvarPERF_MEM_LOCK_NA = 0x01

locked instruction not available

enumvarPERF_MEM_LOCK_LOCKED = 0x02

locked transaction

enumvarPERF_MEM_LOCK_SHIFT = 24
enumvarPERF_MEM_TLB_NA = 0x01

not available

enumvarPERF_MEM_TLB_HIT = 0x02

hit level

enumvarPERF_MEM_TLB_MISS = 0x04

miss level

enumvarPERF_MEM_TLB_L1 = 0x08

L1

enumvarPERF_MEM_TLB_L2 = 0x10

L2

enumvarPERF_MEM_TLB_WK = 0x20

Hardware Walker

enumvarPERF_MEM_TLB_OS = 0x40

OS fault handler

enumvarPERF_MEM_TLB_SHIFT = 26