Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

core.sys.linux.perf_event

D header file for perf_event_open system call.
Converted from linux userspace header, comments included.
Authors:
Max Haughton
enum perf_type_id: int;
attr.type
enum perf_hw_id: int;
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
PERF_COUNT_HW_INSTRUCTIONS
PERF_COUNT_HW_CACHE_REFERENCES
PERF_COUNT_HW_CACHE_MISSES
PERF_COUNT_HW_BRANCH_INSTRUCTIONS
PERF_COUNT_HW_BRANCH_MISSES
PERF_COUNT_HW_BUS_CYCLES
PERF_COUNT_HW_STALLED_CYCLES_FRONTEND
PERF_COUNT_HW_STALLED_CYCLES_BACKEND
PERF_COUNT_HW_REF_CPU_CYCLES
PERF_COUNT_HW_MAX
enum perf_hw_cache_id: int;
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
PERF_COUNT_HW_CACHE_L1I
PERF_COUNT_HW_CACHE_LL
PERF_COUNT_HW_CACHE_DTLB
PERF_COUNT_HW_CACHE_ITLB
PERF_COUNT_HW_CACHE_BPU
PERF_COUNT_HW_CACHE_NODE
PERF_COUNT_HW_CACHE_MAX
enum perf_hw_cache_op_id: int;
PERF_COUNT_HW_CACHE_OP_READ
PERF_COUNT_HW_CACHE_OP_WRITE
PERF_COUNT_HW_CACHE_OP_PREFETCH
PERF_COUNT_HW_CACHE_OP_MAX
enum perf_hw_cache_op_result_id: int;
PERF_COUNT_HW_CACHE_RESULT_ACCESS
PERF_COUNT_HW_CACHE_RESULT_MISS
PERF_COUNT_HW_CACHE_RESULT_MAX
enum perf_sw_ids: int;
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
PERF_COUNT_SW_TASK_CLOCK
PERF_COUNT_SW_PAGE_FAULTS
PERF_COUNT_SW_CONTEXT_SWITCHES
PERF_COUNT_SW_CPU_MIGRATIONS
PERF_COUNT_SW_PAGE_FAULTS_MIN
PERF_COUNT_SW_PAGE_FAULTS_MAJ
PERF_COUNT_SW_ALIGNMENT_FAULTS
PERF_COUNT_SW_EMULATION_FAULTS
PERF_COUNT_SW_DUMMY
PERF_COUNT_SW_BPF_OUTPUT
PERF_COUNT_SW_MAX
enum perf_event_sample_format: uint;
Bits that can be set in attr.sample_type to request information in the overflow packets.
PERF_SAMPLE_IP
PERF_SAMPLE_TID
PERF_SAMPLE_TIME
PERF_SAMPLE_ADDR
PERF_SAMPLE_READ
PERF_SAMPLE_CALLCHAIN
PERF_SAMPLE_ID
PERF_SAMPLE_CPU
PERF_SAMPLE_PERIOD
PERF_SAMPLE_STREAM_ID
PERF_SAMPLE_RAW
PERF_SAMPLE_BRANCH_STACK
PERF_SAMPLE_REGS_USER
PERF_SAMPLE_STACK_USER
PERF_SAMPLE_WEIGHT
PERF_SAMPLE_DATA_SRC
PERF_SAMPLE_IDENTIFIER
PERF_SAMPLE_TRANSACTION
PERF_SAMPLE_REGS_INTR
PERF_SAMPLE_PHYS_ADDR
PERF_SAMPLE_MAX
enum perf_branch_sample_type_shift: int;
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
user branches
PERF_SAMPLE_BRANCH_KERNEL_SHIFT
kernel branches
PERF_SAMPLE_BRANCH_HV_SHIFT
hypervisor branches
PERF_SAMPLE_BRANCH_ANY_SHIFT
any branch types
PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT
any call branch
PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT
any return branch
PERF_SAMPLE_BRANCH_IND_CALL_SHIFT
indirect calls
PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT
transaction aborts
PERF_SAMPLE_BRANCH_IN_TX_SHIFT
in transaction
PERF_SAMPLE_BRANCH_NO_TX_SHIFT
not in transaction
PERF_SAMPLE_BRANCH_COND_SHIFT
conditional branches
PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT
call/ret stack
PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT
indirect jumps
PERF_SAMPLE_BRANCH_CALL_SHIFT
direct call
PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT
no flags
PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT
no cycles
PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT
save branch type
PERF_SAMPLE_BRANCH_MAX_SHIFT
non-ABI
enum perf_branch_sample_type: uint;
PERF_BR_UNKNOWN
unknown
PERF_BR_COND
conditional
PERF_BR_UNCOND
unconditional
PERF_BR_IND
indirect
PERF_BR_CALL
function call
PERF_BR_IND_CALL
indirect function call
PERF_BR_RET
function return
PERF_BR_SYSCALL
syscall
PERF_BR_SYSRET
syscall return
PERF_BR_COND_CALL
conditional function call
PERF_BR_COND_RET
conditional function return
enum perf_branch_sample_type PERF_SAMPLE_BRANCH_PLM_ALL;
enum perf_sample_regs_abi: int;
Values to determine ABI of the registers dump.
PERF_SAMPLE_REGS_ABI_NONE
PERF_SAMPLE_REGS_ABI_32
PERF_SAMPLE_REGS_ABI_64
PERF_TXN_ELISION
From elision
PERF_TXN_TRANSACTION
From transaction
PERF_TXN_SYNC
Instruction is related
PERF_TXN_ASYNC
Instruction not related
PERF_TXN_RETRY
Retry possible
PERF_TXN_CONFLICT
Conflict abort
PERF_TXN_CAPACITY_WRITE
Capacity write abort
PERF_TXN_CAPACITY_READ
Capacity read abort
PERF_TXN_MAX
non-ABI
PERF_TXN_ABORT_SHIFT
bits 32..63 are reserved for the abort code
PERF_TXN_ABORT_MASK = 0xffffffff << 32,
enum perf_event_read_format: uint;
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
PERF_FORMAT_TOTAL_TIME_RUNNING
PERF_FORMAT_ID
PERF_FORMAT_GROUP
PERF_FORMAT_MAX
non-ABI
enum int PERF_ATTR_SIZE_VER0;
sizeof first published struct
enum int PERF_ATTR_SIZE_VER1;
add: config2
enum int PERF_ATTR_SIZE_VER2;
add: branch_sample_type
enum int PERF_ATTR_SIZE_VER3;
add: sample_regs_user
enum int PERF_ATTR_SIZE_VER4;
add: sample_regs_intr
enum int PERF_ATTR_SIZE_VER5;
add: aux_watermark
struct perf_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
uint type;
Major type: hardware/software/tracepoint/etc.
uint size;
Size of the attr structure, for fwd/bwd compat.
ulong config;
Type specific configuration information.
ulong sample_period;
ulong sample_freq;
ulong sample_type;
ulong read_format;
pure nothrow @nogc @property @safe ulong disabled() const;
pure nothrow @nogc @property @safe void disabled(ulong v);
pure nothrow @nogc @property @safe ulong inherit() const;
pure nothrow @nogc @property @safe void inherit(ulong v);
pure nothrow @nogc @property @safe ulong pinned() const;
pure nothrow @nogc @property @safe void pinned(ulong v);
pure nothrow @nogc @property @safe ulong exclusive() const;
pure nothrow @nogc @property @safe void exclusive(ulong v);
pure nothrow @nogc @property @safe ulong exclude_user() const;
pure nothrow @nogc @property @safe void exclude_user(ulong v);
pure nothrow @nogc @property @safe ulong exclude_kernel() const;
pure nothrow @nogc @property @safe void exclude_kernel(ulong v);
pure nothrow @nogc @property @safe ulong exclude_hv() const;
pure nothrow @nogc @property @safe void exclude_hv(ulong v);
pure nothrow @nogc @property @safe ulong exclude_idle() const;
pure nothrow @nogc @property @safe void exclude_idle(ulong v);
pure nothrow @nogc @property @safe ulong mmap() const;
pure nothrow @nogc @property @safe void mmap(ulong v);
pure nothrow @nogc @property @safe ulong comm() const;
pure nothrow @nogc @property @safe void comm(ulong v);
pure nothrow @nogc @property @safe ulong freq() const;
pure nothrow @nogc @property @safe void freq(ulong v);
pure nothrow @nogc @property @safe ulong inherit_stat() const;
pure nothrow @nogc @property @safe void inherit_stat(ulong v);
pure nothrow @nogc @property @safe ulong enable_on_exec() const;
pure nothrow @nogc @property @safe void enable_on_exec(ulong v);
pure nothrow @nogc @property @safe ulong task() const;
pure nothrow @nogc @property @safe void task(ulong v);
pure nothrow @nogc @property @safe ulong watermark() const;
pure nothrow @nogc @property @safe void watermark(ulong v);
pure nothrow @nogc @property @safe ulong precise_ip() const;
pure nothrow @nogc @property @safe void precise_ip(ulong v);
pure nothrow @nogc @property @safe ulong mmap_data() const;
pure nothrow @nogc @property @safe void mmap_data(ulong v);
pure nothrow @nogc @property @safe ulong sample_id_all() const;
pure nothrow @nogc @property @safe void sample_id_all(ulong v);
pure nothrow @nogc @property @safe ulong exclude_host() const;
pure nothrow @nogc @property @safe void exclude_host(ulong v);
pure nothrow @nogc @property @safe ulong exclude_guest() const;
pure nothrow @nogc @property @safe void exclude_guest(ulong v);
pure nothrow @nogc @property @safe ulong exclude_callchain_kernel() const;
pure nothrow @nogc @property @safe void exclude_callchain_kernel(ulong v);
pure nothrow @nogc @property @safe ulong exclude_callchain_user() const;
pure nothrow @nogc @property @safe void exclude_callchain_user(ulong v);
pure nothrow @nogc @property @safe ulong mmap2() const;
pure nothrow @nogc @property @safe void mmap2(ulong v);
pure nothrow @nogc @property @safe ulong comm_exec() const;
pure nothrow @nogc @property @safe void comm_exec(ulong v);
pure nothrow @nogc @property @safe ulong use_clockid() const;
pure nothrow @nogc @property @safe void use_clockid(ulong v);
pure nothrow @nogc @property @safe ulong context_switch() const;
pure nothrow @nogc @property @safe void context_switch(ulong v);
pure nothrow @nogc @property @safe ulong write_backward() const;
pure nothrow @nogc @property @safe void write_backward(ulong v);
pure nothrow @nogc @property @safe ulong namespaces() const;
pure nothrow @nogc @property @safe void namespaces(ulong v);
pure nothrow @nogc @property @safe ulong __reserved_1() const;
pure nothrow @nogc @property @safe void __reserved_1(ulong v);
uint wakeup_events;
wakeup every n events
uint wakeup_watermark;
bytes before wakeup
uint bp_type;
ulong bp_addr;
ulong config1;
extension of config
ulong bp_len;
ulong config2;
extension of config1
ulong branch_sample_type;
enum perf_branch_sample_type
ulong sample_regs_user;
Defines set of user regs to dump on samples. See asm/perf_regs.h for details.
uint sample_stack_user;
Defines size of the user stack to dump on samples.
int clockid;
ulong sample_regs_intr;
Defines set of regs to dump for each sample state captured on:
  • precise = 0: PMU interrupt
  • precise > 0: sampled instruction
See asm/perf_regs.h for details.
uint aux_watermark;
Wakeup watermark for AUX area
ushort sample_max_stack;
ushort __reserved_2;
align to _u64
auto perf_flags(T)(auto ref T attr);
enum int PERF_EVENT_IOC_ENABLE;
Ioctls that can be done on a perf event fd:
enum int PERF_EVENT_IOC_DISABLE;
enum int PERF_EVENT_IOC_REFRESH;
enum int PERF_EVENT_IOC_RESET;
enum int PERF_EVENT_IOC_PERIOD;
enum int PERF_EVENT_IOC_SET_OUTPUT;
enum int PERF_EVENT_IOC_SET_FILTER;
enum int PERF_EVENT_IOC_ID;
enum int PERF_EVENT_IOC_SET_BPF;
enum int PERF_EVENT_IOC_PAUSE_OUTPUT;
enum perf_event_ioc_flags: uint;
struct perf_event_mmap_page;
Structure of the page that can be mapped via mmap
uint version_;
version number of this structure
uint compat_version;
lowest version this is compat with
uint lock;
Bits needed to read the hw events in user-space.
u32 seq, time_mult, time_shift, index, width;
u64 count, enabled, running;
u64 cyc, time_offset;
s64 pmc = 0;

do {
  seq = pc->lock;
  barrier()

  enabled = pc->time_enabled;
  running = pc->time_running;

  if (pc->cap_usr_time && enabled != running) {
    cyc = rdtsc();
    time_offset = pc->time_offset;
    time_mult   = pc->time_mult;
    time_shift  = pc->time_shift;
  }

  index = pc->index;
  count = pc->offset;
  if (pc->cap_user_rdpmc && index) {
    width = pc->pmc_width;
    pmc = rdpmc(index - 1);
  }

  barrier();
} while (pc->lock != seq);

NOTE for obvious reason this only works on self-monitoring processes.

seqlock for synchronization

uint index;
hardware event identifier
long offset;
add to hardware event value
ulong time_enabled;
time event active
ulong time_running;
time event on cpu
ulong capabilities;
pure nothrow @nogc @property @safe ulong cap_bit0() const;
pure nothrow @nogc @property @safe void cap_bit0(ulong v);
enum ulong cap_bit0_min;
enum ulong cap_bit0_max;
pure nothrow @nogc @property @safe ulong cap_bit0_is_deprecated() const;
pure nothrow @nogc @property @safe void cap_bit0_is_deprecated(ulong v);
enum ulong cap_bit0_is_deprecated_min;
enum ulong cap_bit0_is_deprecated_max;
pure nothrow @nogc @property @safe ulong cap_user_rdpmc() const;
pure nothrow @nogc @property @safe void cap_user_rdpmc(ulong v);
enum ulong cap_user_rdpmc_min;
enum ulong cap_user_rdpmc_max;
pure nothrow @nogc @property @safe ulong cap_user_time() const;
pure nothrow @nogc @property @safe void cap_user_time(ulong v);
enum ulong cap_user_time_min;
enum ulong cap_user_time_max;
pure nothrow @nogc @property @safe ulong cap_user_time_zero() const;
pure nothrow @nogc @property @safe void cap_user_time_zero(ulong v);
enum ulong cap_user_time_zero_min;
enum ulong cap_user_time_zero_max;
pure nothrow @nogc @property @safe ulong cap_____res() const;
pure nothrow @nogc @property @safe void cap_____res(ulong v);
enum ulong cap_____res_min;
enum ulong cap_____res_max;
ushort pmc_width;
If cap_user_rdpmc 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:
pmc <<= 64 - width; pmc >>= 64 - width; // signed shift right count += pmc;
ushort time_shift;
If cap_usr_time the below fields can be used to compute the time delta since time_enabled (in ns) using rdtsc or similar.
u64 quot, rem; u64 delta;
quot = (cyc >> time_shift); rem = cyc & (((u64)1 << time_shift) - 1); delta = time_offset + quot * time_mult + ((rem * time_mult) >> time_shift);
Where time_offset,time_mult,time_shift and cyc are read in the seqcount loop described above. This delta can then be added to enabled and possible running (if index), improving the scaling:
enabled += delta; if (index) running += delta;
quot = count / running; rem = count % running; count = quot * enabled + (rem * enabled) / running;
uint time_mult;
ulong time_offset;
ulong time_zero;
If cap_usr_time_zero, the hardware clock (e.g. TSC) can be calculated from sample timestamps.
time = timestamp - time_zero; quot = time / time_mult; rem = time % time_mult; cyc = (quot << time_shift) + (rem << time_shift) / time_mult;
And vice versa:
quot = cyc >> time_shift; rem = cyc & (((u64)1 << time_shift) - 1); timestamp = time_zero + quot * time_mult + ((rem * time_mult) >> time_shift);
uint size;
Header size up to _reserved[] fields.
ubyte[948] __reserved;
Hole for extension of the self monitor capabilities
align to 1k.
ulong data_head;
Control data for the mmap() data buffer.
User-space reading the @data_head value should issue an smp_rmb(), after reading this value.
When the mapping is PROT_WRITE the @data_tail value should be written by userspace to reflect the last read data, after issueing an smp_mb() to separate the data read from the ->data_tail store. In this case the kernel will not over-write unread data.
See perf_output_put_handle() for the data ordering.
data_{offset,size} indicate the location and size of the perf record buffer within the mmapped area.
head in the data section
ulong data_tail;
user-space written tail
ulong data_offset;
where the buffer starts
ulong data_size;
data buffer size
ulong aux_head;
AUX area is defined by aux_{offset,size} fields that should be set by the userspace, so that
aux_offset >= data_offset + data_size
prior to mmap()ing it. Size of the mmap()ed area should be aux_size.
Ring buffer pointers aux_{head,tail} have the same semantics as data_{head,tail} and same ordering rules apply.
ulong aux_tail;
ulong aux_offset;
ulong aux_size;
enum int PERF_RECORD_MISC_CPUMODE_MASK;
enum int PERF_RECORD_MISC_CPUMODE_UNKNOWN;
enum int PERF_RECORD_MISC_KERNEL;
enum int PERF_RECORD_MISC_USER;
enum int PERF_RECORD_MISC_HYPERVISOR;
enum int PERF_RECORD_MISC_GUEST_KERNEL;
enum int PERF_RECORD_MISC_GUEST_USER;
enum int PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT;
Indicates that /proc/PID/maps parsing are truncated by time out.
enum int PERF_RECORD_MISC_MMAP_DATA;
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.
enum int PERF_RECORD_MISC_COMM_EXEC;
enum int PERF_RECORD_MISC_SWITCH_OUT;
enum int PERF_RECORD_MISC_EXACT_IP;
Indicates that the content of PERF_SAMPLE_IP points to the actual instruction that triggered the event. See also perf_event_attr::precise_ip.
enum int PERF_RECORD_MISC_EXT_RESERVED;
Reserve the last bit to indicate some extended misc field
struct perf_event_header;
uint type;
ushort misc;
ushort size;
struct perf_ns_link_info;
ulong dev;
ulong ino;
NET_NS_INDEX
UTS_NS_INDEX
IPC_NS_INDEX
PID_NS_INDEX
USER_NS_INDEX
MNT_NS_INDEX
CGROUP_NS_INDEX
NR_NAMESPACES
number of available namespaces
enum perf_event_type: int;
PERF_RECORD_MMAP
If perf_event_attr.sample_id_all is set then all event types will have the sample_type selected fields related to where/when (identity) an event took place (TID, TIME, ID, STREAM_ID, CPU, IDENTIFIER) described in PERF_RECORD_SAMPLE below, it will be stashed just after the perf_event_header and the fields already present for the existing fields, i.e. 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.
struct sample_id {
    { u32            pid, tid; } && PERF_SAMPLE_TID
    { u64            time;     } && PERF_SAMPLE_TIME
    { u64            id;       } && PERF_SAMPLE_ID
    { u64            stream_id;} && PERF_SAMPLE_STREAM_ID
    { u32            cpu, res; } && PERF_SAMPLE_CPU
   { u64            id;      } && PERF_SAMPLE_IDENTIFIER
} && perf_event_attr::sample_id_all
Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID. The advantage of PERF_SAMPLE_IDENTIFIER is that its position is fixed relative to header.size.
PERF_RECORD_LOST
struct {
   struct perf_event_header    header;
   u64                id;
   u64                lost;
    struct sample_id        sample_id;
};
PERF_RECORD_COMM
struct {
   struct perf_event_header    header;

   u32                pid, tid;
   char                comm[];
    struct sample_id        sample_id;
};
PERF_RECORD_EXIT
struct {
   struct perf_event_header    header;
   u32                pid, ppid;
   u32                tid, ptid;
   u64                time;
    struct sample_id        sample_id;
};
PERF_RECORD_THROTTLE
struct {
   struct perf_event_header    header;
   u64                time;
   u64                id;
   u64                stream_id;
   struct sample_id        sample_id;
};
PERF_RECORD_FORK
struct {
   struct perf_event_header    header;
   u32                pid, ppid;
   u32                tid, ptid;
   u64                time;
    struct sample_id        sample_id;
};
PERF_RECORD_READ
struct {
   struct perf_event_header    header;
   u32                pid, tid;

   struct read_format        values;
    struct sample_id        sample_id;
};
PERF_RECORD_SAMPLE
struct {
   struct perf_event_header    header;

   #
   # Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID.
   # The advantage of PERF_SAMPLE_IDENTIFIER is that its position
   # is fixed relative to header.
   #

   { u64            id;      } && PERF_SAMPLE_IDENTIFIER
   { u64            ip;      } && PERF_SAMPLE_IP
   { u32            pid, tid; } && PERF_SAMPLE_TID
   { u64            time;     } && PERF_SAMPLE_TIME
   { u64            addr;     } && PERF_SAMPLE_ADDR
   { u64            id;      } && PERF_SAMPLE_ID
   { u64            stream_id;} && PERF_SAMPLE_STREAM_ID
   { u32            cpu, res; } && PERF_SAMPLE_CPU
   { u64            period;   } && PERF_SAMPLE_PERIOD

   { struct read_format    values;      } && PERF_SAMPLE_READ

   { u64            nr,
     u64            ips[nr];  } && PERF_SAMPLE_CALLCHAIN

   #
   # The RAW record below is opaque data wrt the ABI
   #
   # That is, the ABI doesn't make any promises wrt to
   # the stability of its content, it may vary depending
   # on event, hardware, kernel version and phase of
   # the moon.
   #
   # In other words, PERF_SAMPLE_RAW contents are not an ABI.
   #

   { u32            size;
     char                  data[size];}&& PERF_SAMPLE_RAW

   { u64                   nr;
       { u64 from, to, flags } lbr[nr];} && PERF_SAMPLE_BRANCH_STACK

    { u64            abi; # enum perf_sample_regs_abi
      u64            regs[weight(mask)]; } && PERF_SAMPLE_REGS_USER

    { u64            size;
      char            data[size];
      u64            dyn_size; } && PERF_SAMPLE_STACK_USER

   { u64            weight;   } && PERF_SAMPLE_WEIGHT
   { u64            data_src; } && PERF_SAMPLE_DATA_SRC
   { u64            transaction; } && PERF_SAMPLE_TRANSACTION
   { u64            abi; # enum perf_sample_regs_abi
     u64            regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR
   { u64            phys_addr;} && PERF_SAMPLE_PHYS_ADDR
};
PERF_RECORD_MMAP2
The MMAP2 records are an augmented version of MMAP, they add
maj, min, ino numbers to be used to uniquely identify each mapping

struct {
   struct perf_event_header    header;

   u32                pid, tid;
   u64                addr;
   u64                len;
   u64                pgoff;
   u32                maj;
   u32                min;
   u64                ino;
   u64                ino_generation;
   u32                prot, flags;
   char                filename[];
    struct sample_id        sample_id;
};
PERF_RECORD_AUX
Records that new data landed in the AUX buffer part.
struct {
    struct perf_event_header    header;

    u64                aux_offset;
    u64                aux_size;
   u64                flags;
    struct sample_id        sample_id;
};
PERF_RECORD_ITRACE_START
Indicates that instruction trace has started

struct {
   struct perf_event_header    header;
   u32                pid;
   u32                tid;
};
PERF_RECORD_LOST_SAMPLES
Records the dropped/lost sample number.
struct {
   struct perf_event_header    header;

   u64                lost;
   struct sample_id        sample_id;
};
PERF_RECORD_SWITCH
Records a context switch in or out (flagged by PERF_RECORD_MISC_SWITCH_OUT). See also PERF_RECORD_SWITCH_CPU_WIDE.
struct {
   struct perf_event_header    header;
   struct sample_id        sample_id;
};
PERF_RECORD_SWITCH_CPU_WIDE
CPU-wide version of PERF_RECORD_SWITCH with next_prev_pid and next_prev_tid that are the next (switching out) or previous (switching in) pid/tid.
struct {
  struct perf_event_header    header;
  u32                next_prev_pid;
  u32                next_prev_tid;
  struct sample_id        sample_id;
};
PERF_RECORD_NAMESPACES
struct {
   struct perf_event_header    header;
   u32                pid;
   u32                tid;
   u64                nr_namespaces;
   { u64                dev, inode; } [nr_namespaces];
   struct sample_id        sample_id;
};
enum int PERF_MAX_STACK_DEPTH;
enum int PERF_MAX_CONTEXTS_PER_STACK;
enum perf_callchain_context: ulong;
PERF_CONTEXT_HV
PERF_CONTEXT_KERNEL
PERF_CONTEXT_USER
PERF_CONTEXT_GUEST
PERF_CONTEXT_GUEST_KERNEL
PERF_CONTEXT_GUEST_USER
PERF_CONTEXT_MAX
enum int PERF_AUX_FLAG_TRUNCATED;
PERF_RECORD_AUX::flags bits
record was truncated to fit
enum int PERF_AUX_FLAG_OVERWRITE;
snapshot from overwrite mode
enum int PERF_AUX_FLAG_PARTIAL;
record contains gaps
enum int PERF_AUX_FLAG_COLLISION;
sample collided with another
enum ulong PERF_FLAG_FD_NO_GROUP;
enum ulong PERF_FLAG_FD_OUTPUT;
enum ulong PERF_FLAG_PID_CGROUP;
pid=cgroup id, per-cpu mode only
enum ulong PERF_FLAG_FD_CLOEXEC;
O_CLOEXEC
union perf_mem_data_src;
perm_mem_data_src is endian specific.
ulong val;
pure nothrow @nogc @property @safe ulong mem_op() const;
pure nothrow @nogc @property @safe void mem_op(ulong v);
pure nothrow @nogc @property @safe ulong mem_lvl() const;
pure nothrow @nogc @property @safe void mem_lvl(ulong v);
pure nothrow @nogc @property @safe ulong mem_snoop() const;
pure nothrow @nogc @property @safe void mem_snoop(ulong v);
pure nothrow @nogc @property @safe ulong mem_lock() const;
pure nothrow @nogc @property @safe void mem_lock(ulong v);
pure nothrow @nogc @property @safe ulong mem_dtlb() const;
pure nothrow @nogc @property @safe void mem_dtlb(ulong v);
pure nothrow @nogc @property @safe ulong mem_lvl_num() const;
pure nothrow @nogc @property @safe void mem_lvl_num(ulong v);
pure nothrow @nogc @property @safe ulong mem_remote() const;
pure nothrow @nogc @property @safe void mem_remote(ulong v);
pure nothrow @nogc @property @safe ulong mem_snoopx() const;
pure nothrow @nogc @property @safe void mem_snoopx(ulong v);
pure nothrow @nogc @property @safe ulong mem_rsvd() const;
pure nothrow @nogc @property @safe void mem_rsvd(ulong v);
enum int PERF_MEM_OP_NA;
type of opcode (load/store/prefetch,code)
not available
enum int PERF_MEM_OP_LOAD;
load instruction
enum int PERF_MEM_OP_STORE;
store instruction
enum int PERF_MEM_OP_PFETCH;
prefetch
enum int PERF_MEM_OP_EXEC;
code (execution)
enum int PERF_MEM_LVL_NA;
not available
enum int PERF_MEM_LVL_HIT;
hit level
enum int PERF_MEM_LVL_MISS;
miss level
enum int PERF_MEM_LVL_L1;
L1
enum int PERF_MEM_LVL_LFB;
Line Fill Buffer
enum int PERF_MEM_LVL_L2;
L2
enum int PERF_MEM_LVL_L3;
L3
enum int PERF_MEM_LVL_LOC_RAM;
Local DRAM
enum int PERF_MEM_LVL_REM_RAM1;
Remote DRAM (1 hop)
enum int PERF_MEM_LVL_REM_RAM2;
Remote DRAM (2 hops)
enum int PERF_MEM_LVL_REM_CCE1;
Remote Cache (1 hop)
enum int PERF_MEM_LVL_REM_CCE2;
Remote Cache (2 hops)
enum int PERF_MEM_LVL_IO;
I/O memory
enum int PERF_MEM_LVL_UNC;
Uncached memory
enum int PERF_MEM_LVL_SHIFT;
enum int PERF_MEM_REMOTE_REMOTE;
Remote
enum int PERF_MEM_REMOTE_SHIFT;
enum int PERF_MEM_LVLNUM_L1;
L1
enum int PERF_MEM_LVLNUM_L2;
L2
enum int PERF_MEM_LVLNUM_L3;
L3
enum int PERF_MEM_LVLNUM_L4;
L4
enum int PERF_MEM_LVLNUM_ANY_CACHE;
Any cache
enum int PERF_MEM_LVLNUM_LFB;
LFB
enum int PERF_MEM_LVLNUM_RAM;
RAM
enum int PERF_MEM_LVLNUM_PMEM;
PMEM
enum int PERF_MEM_LVLNUM_NA;
N/A
enum int PERF_MEM_LVLNUM_SHIFT;
enum int PERF_MEM_SNOOP_NA;
not available
enum int PERF_MEM_SNOOP_NONE;
no snoop
enum int PERF_MEM_SNOOP_HIT;
snoop hit
enum int PERF_MEM_SNOOP_MISS;
snoop miss
enum int PERF_MEM_SNOOP_HITM;
snoop hit modified
enum int PERF_MEM_SNOOP_SHIFT;
enum int PERF_MEM_SNOOPX_FWD;
forward
enum int PERF_MEM_SNOOPX_SHIFT;
1 free
enum int PERF_MEM_LOCK_NA;
locked instruction
not available
enum int PERF_MEM_LOCK_LOCKED;
locked transaction
enum int PERF_MEM_LOCK_SHIFT;
enum int PERF_MEM_TLB_NA;
not available
enum int PERF_MEM_TLB_HIT;
hit level
enum int PERF_MEM_TLB_MISS;
miss level
enum int PERF_MEM_TLB_L1;
L1
enum int PERF_MEM_TLB_L2;
L2
enum int PERF_MEM_TLB_WK;
Hardware Walker
enum int PERF_MEM_TLB_OS;
OS fault handler
enum int PERF_MEM_TLB_SHIFT;
struct perf_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
ulong from;
ulong to;
pure nothrow @nogc @property @safe ulong mispred() const;
pure nothrow @nogc @property @safe void mispred(ulong v);
pure nothrow @nogc @property @safe ulong predicted() const;
pure nothrow @nogc @property @safe void predicted(ulong v);
pure nothrow @nogc @property @safe ulong in_tx() const;
pure nothrow @nogc @property @safe void in_tx(ulong v);
pure nothrow @nogc @property @safe ulong abort() const;
pure nothrow @nogc @property @safe void abort(ulong v);
pure nothrow @nogc @property @safe ulong cycles() const;
pure nothrow @nogc @property @safe void cycles(ulong v);
pure nothrow @nogc @property @safe ulong type() const;
pure nothrow @nogc @property @safe void type(ulong v);
pure nothrow @nogc @property @safe ulong reserved() const;
pure nothrow @nogc @property @safe void reserved(ulong v);