^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __PERF_RECORD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __PERF_RECORD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * The linux/stddef.h isn't need here, but is needed for __always_inline used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * in files included from uapi/linux/perf_event.h such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * /usr/include/linux/swab.h and /usr/include/linux/byteorder/little_endian.h,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * detected in at least musl libc, used in Alpine Linux. -acme
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <perf/event.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "perf_regs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct dso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct machine;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct perf_event_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #ifdef __LP64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * /usr/include/inttypes.h uses just 'lu' for PRIu64, but we end up defining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * __u64 as long long unsigned int, and then -Werror=format= kicks in and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * complains of the mismatched types, so use these two special extra PRI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * macros to overcome that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define PRI_lu64 "l" PRIu64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define PRI_lx64 "l" PRIx64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define PRI_ld64 "l" PRId64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define PRI_lu64 PRIu64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define PRI_lx64 PRIx64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define PRI_ld64 PRId64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define PERF_SAMPLE_MASK \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) (PERF_SAMPLE_IP | PERF_SAMPLE_TID | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) PERF_SAMPLE_IDENTIFIER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* perf sample has 16 bits size limit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define PERF_SAMPLE_MAX_SIZE (1 << 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct regs_dump {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) u64 abi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) u64 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) u64 *regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* Cached values/mask filled by first register access. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) u64 cache_regs[PERF_REGS_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) u64 cache_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct stack_dump {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u16 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) u64 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) char *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct sample_read_value {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u64 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) u64 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct sample_read {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) u64 time_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) u64 time_running;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u64 nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct sample_read_value *values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) } group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct sample_read_value one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct ip_callchain {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) u64 nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) u64 ips[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct branch_stack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) PERF_IP_FLAG_BRANCH = 1ULL << 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) PERF_IP_FLAG_CALL = 1ULL << 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) PERF_IP_FLAG_RETURN = 1ULL << 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) PERF_IP_FLAG_CONDITIONAL = 1ULL << 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) PERF_IP_FLAG_SYSCALLRET = 1ULL << 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) PERF_IP_FLAG_ASYNC = 1ULL << 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) PERF_IP_FLAG_INTERRUPT = 1ULL << 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) PERF_IP_FLAG_TX_ABORT = 1ULL << 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) PERF_IP_FLAG_TRACE_BEGIN = 1ULL << 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) PERF_IP_FLAG_TRACE_END = 1ULL << 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) PERF_IP_FLAG_IN_TX = 1ULL << 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define PERF_IP_FLAG_CHARS "bcrosyiABEx"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define PERF_BRANCH_MASK (\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) PERF_IP_FLAG_BRANCH |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) PERF_IP_FLAG_CALL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) PERF_IP_FLAG_RETURN |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) PERF_IP_FLAG_CONDITIONAL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) PERF_IP_FLAG_SYSCALLRET |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) PERF_IP_FLAG_ASYNC |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) PERF_IP_FLAG_INTERRUPT |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) PERF_IP_FLAG_TX_ABORT |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) PERF_IP_FLAG_TRACE_BEGIN |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) PERF_IP_FLAG_TRACE_END)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define MAX_INSN 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct aux_sample {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) u64 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) void *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct perf_sample {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) u64 ip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) u32 pid, tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) u64 time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) u64 addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) u64 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) u64 stream_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) u64 period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) u64 weight;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) u64 transaction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) u64 insn_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) u64 cyc_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) u32 cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) u32 raw_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) u64 data_src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) u64 phys_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) u64 cgroup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) u16 insn_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) u8 cpumode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) u16 misc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) bool no_hw_idx; /* No hw_idx collected in branch_stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) char insn[MAX_INSN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) void *raw_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct ip_callchain *callchain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct branch_stack *branch_stack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct regs_dump user_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct regs_dump intr_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct stack_dump user_stack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct sample_read read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct aux_sample aux_sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define PERF_MEM_DATA_SRC_NONE \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) (PERF_MEM_S(OP, NA) |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) PERF_MEM_S(LVL, NA) |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) PERF_MEM_S(SNOOP, NA) |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) PERF_MEM_S(LOCK, NA) |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) PERF_MEM_S(TLB, NA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /* Attribute type for custom synthesized events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #define PERF_TYPE_SYNTH (INT_MAX + 1U)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /* Attribute config for custom synthesized events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) enum perf_synth_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) PERF_SYNTH_INTEL_PTWRITE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) PERF_SYNTH_INTEL_MWAIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) PERF_SYNTH_INTEL_PWRE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) PERF_SYNTH_INTEL_EXSTOP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) PERF_SYNTH_INTEL_PWRX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) PERF_SYNTH_INTEL_CBR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * Raw data formats for synthesized events. Note that 4 bytes of padding are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * present to match the 'size' member of PERF_SAMPLE_RAW data which is always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * 8-byte aligned. That means we must dereference raw_data with an offset of 4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * Refer perf_sample__synth_ptr() and perf_synth__raw_data(). It also means the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * structure sizes are 4 bytes bigger than the raw_size, refer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * perf_synth__raw_size().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct perf_synth_intel_ptwrite {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) u32 ip : 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) reserved : 31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) u64 payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct perf_synth_intel_mwait {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) u64 hints : 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) reserved1 : 24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) extensions : 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) reserved2 : 30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) u64 payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct perf_synth_intel_pwre {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) u64 reserved1 : 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) hw : 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) subcstate : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) cstate : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) reserved2 : 48;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) u64 payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct perf_synth_intel_exstop {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) u32 ip : 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) reserved : 31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) struct perf_synth_intel_pwrx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) u64 deepest_cstate : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) last_cstate : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) wake_reason : 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) reserved1 : 52;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) u64 payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) struct perf_synth_intel_cbr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) u32 cbr : 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) reserved1 : 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) max_nonturbo : 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) reserved2 : 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) u32 freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) u32 reserved3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * raw_data is always 4 bytes from an 8-byte boundary, so subtract 4 to get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * 8-byte alignment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static inline void *perf_sample__synth_ptr(struct perf_sample *sample)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) return sample->raw_data - 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) static inline void *perf_synth__raw_data(void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return p + 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) #define perf_synth__raw_size(d) (sizeof(d) - 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) #define perf_sample__bad_synth_size(s, d) ((s)->raw_size < sizeof(d) - 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) PERF_STAT_ROUND_TYPE__INTERVAL = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) PERF_STAT_ROUND_TYPE__FINAL = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) void perf_event__print_totals(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct perf_cpu_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct perf_record_stat_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) struct perf_stat_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct perf_tool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) void perf_event__read_stat_config(struct perf_stat_config *config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) struct perf_record_stat_config *event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) int perf_event__process_comm(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) int perf_event__process_lost(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) int perf_event__process_lost_samples(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) int perf_event__process_aux(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) int perf_event__process_itrace_start(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) int perf_event__process_switch(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) int perf_event__process_namespaces(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) int perf_event__process_cgroup(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) int perf_event__process_mmap(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) int perf_event__process_mmap2(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) int perf_event__process_fork(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) int perf_event__process_exit(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) int perf_event__process_ksymbol(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) int perf_event__process_bpf(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) int perf_event__process_text_poke(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) int perf_event__process(struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) struct addr_location;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) int machine__resolve(struct machine *machine, struct addr_location *al,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) struct perf_sample *sample);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) void addr_location__put(struct addr_location *al);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) struct thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) bool is_bts_event(struct perf_event_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) bool sample_addr_correlates_sym(struct perf_event_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) void thread__resolve(struct thread *thread, struct addr_location *al,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) struct perf_sample *sample);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) const char *perf_event__name(unsigned int id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) size_t perf_event__fprintf_task(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) size_t perf_event__fprintf_cgroup(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) size_t perf_event__fprintf_bpf(union perf_event *event, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) size_t perf_event__fprintf_text_poke(union perf_event *event, struct machine *machine,FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) size_t perf_event__fprintf(union perf_event *event, struct machine *machine, FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) int kallsyms__get_function_start(const char *kallsyms_filename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) const char *symbol_name, u64 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf_cpu_map *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) u16 type, int max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) void event_attr_init(struct perf_event_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) int perf_event_paranoid(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) bool perf_event_paranoid_check(int max_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) extern int sysctl_perf_event_max_stack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) extern int sysctl_perf_event_max_contexts_per_stack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) extern unsigned int proc_map_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) #endif /* __PERF_RECORD_H */