1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 #ifndef __PERF_RECORD_H 1 #ifndef __PERF_RECORD_H 3 #define __PERF_RECORD_H 2 #define __PERF_RECORD_H 4 /* !! 3 #include "../perf.h" 5 * The linux/stddef.h isn't need here, but is !! 4 #include "util.h" 6 * in files included from uapi/linux/perf_even !! 5 #include <linux/list.h> 7 * /usr/include/linux/swab.h and /usr/include/ << 8 * detected in at least musl libc, used in Alp << 9 */ << 10 #include <stdio.h> << 11 #include <linux/stddef.h> << 12 #include <perf/event.h> << 13 #include <linux/types.h> << 14 << 15 struct dso; << 16 struct machine; << 17 struct perf_event_attr; << 18 struct perf_sample; << 19 << 20 #ifdef __LP64__ << 21 /* << 22 * /usr/include/inttypes.h uses just 'lu' for << 23 * __u64 as long long unsigned int, and then - << 24 * complains of the mismatched types, so use t << 25 * macros to overcome that. << 26 */ << 27 #define PRI_lu64 "l" PRIu64 << 28 #define PRI_lx64 "l" PRIx64 << 29 #define PRI_ld64 "l" PRId64 << 30 #else << 31 #define PRI_lu64 PRIu64 << 32 #define PRI_lx64 PRIx64 << 33 #define PRI_ld64 PRId64 << 34 #endif << 35 << 36 #define PERF_SAMPLE_MASK << 37 (PERF_SAMPLE_IP | PERF_SAMPLE_TID | << 38 PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | << 39 PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID << 40 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD << 41 PERF_SAMPLE_IDENTIFIER) << 42 << 43 /* perf sample has 16 bits size limit */ << 44 #define PERF_SAMPLE_MAX_SIZE (1 << 16) << 45 << 46 struct ip_callchain { << 47 u64 nr; << 48 u64 ips[]; << 49 }; << 50 << 51 struct branch_stack; << 52 6 53 enum { 7 enum { 54 PERF_IP_FLAG_BRANCH = 1ULL !! 8 SHOW_KERNEL = 1, 55 PERF_IP_FLAG_CALL = 1ULL !! 9 SHOW_USER = 2, 56 PERF_IP_FLAG_RETURN = 1ULL !! 10 SHOW_HV = 4, 57 PERF_IP_FLAG_CONDITIONAL = 1ULL << 58 PERF_IP_FLAG_SYSCALLRET = 1ULL << 59 PERF_IP_FLAG_ASYNC = 1ULL << 60 PERF_IP_FLAG_INTERRUPT = 1ULL << 61 PERF_IP_FLAG_TX_ABORT = 1ULL << 62 PERF_IP_FLAG_TRACE_BEGIN = 1ULL << 63 PERF_IP_FLAG_TRACE_END = 1ULL << 64 PERF_IP_FLAG_IN_TX = 1ULL << 65 PERF_IP_FLAG_VMENTRY = 1ULL << 66 PERF_IP_FLAG_VMEXIT = 1ULL << 67 PERF_IP_FLAG_INTR_DISABLE = 1ULL << 68 PERF_IP_FLAG_INTR_TOGGLE = 1ULL << 69 }; << 70 << 71 #define PERF_IP_FLAG_CHARS "bcrosyiABExghDt" << 72 << 73 #define PERF_BRANCH_MASK (\ << 74 PERF_IP_FLAG_BRANCH |\ << 75 PERF_IP_FLAG_CALL |\ << 76 PERF_IP_FLAG_RETURN |\ << 77 PERF_IP_FLAG_CONDITIONAL |\ << 78 PERF_IP_FLAG_SYSCALLRET |\ << 79 PERF_IP_FLAG_ASYNC |\ << 80 PERF_IP_FLAG_INTERRUPT |\ << 81 PERF_IP_FLAG_TX_ABORT |\ << 82 PERF_IP_FLAG_TRACE_BEGIN |\ << 83 PERF_IP_FLAG_TRACE_END |\ << 84 PERF_IP_FLAG_VMENTRY |\ << 85 PERF_IP_FLAG_VMEXIT) << 86 << 87 #define PERF_MEM_DATA_SRC_NONE \ << 88 (PERF_MEM_S(OP, NA) |\ << 89 PERF_MEM_S(LVL, NA) |\ << 90 PERF_MEM_S(SNOOP, NA) |\ << 91 PERF_MEM_S(LOCK, NA) |\ << 92 PERF_MEM_S(TLB, NA) |\ << 93 PERF_MEM_S(LVLNUM, NA)) << 94 << 95 /* Attribute type for custom synthesized event << 96 #define PERF_TYPE_SYNTH (INT_MAX + 1U) << 97 << 98 /* Attribute config for custom synthesized eve << 99 enum perf_synth_id { << 100 PERF_SYNTH_INTEL_PTWRITE, << 101 PERF_SYNTH_INTEL_MWAIT, << 102 PERF_SYNTH_INTEL_PWRE, << 103 PERF_SYNTH_INTEL_EXSTOP, << 104 PERF_SYNTH_INTEL_PWRX, << 105 PERF_SYNTH_INTEL_CBR, << 106 PERF_SYNTH_INTEL_PSB, << 107 PERF_SYNTH_INTEL_EVT, << 108 PERF_SYNTH_INTEL_IFLAG_CHG, << 109 }; 11 }; 110 12 111 /* 13 /* 112 * Raw data formats for synthesized events. No !! 14 * PERF_SAMPLE_IP | PERF_SAMPLE_TID | * 113 * present to match the 'size' member of PERF_ << 114 * 8-byte aligned. That means we must derefere << 115 * Refer perf_sample__synth_ptr() and perf_syn << 116 * structure sizes are 4 bytes bigger than the << 117 * perf_synth__raw_size(). << 118 */ 15 */ 119 !! 16 struct ip_event { 120 struct perf_synth_intel_ptwrite { !! 17 struct perf_event_header header; 121 u32 padding; !! 18 u64 ip; 122 union { !! 19 u32 pid, tid; 123 struct { !! 20 unsigned char __more_data[]; 124 u32 ip !! 21 }; 125 reserved !! 22 126 }; !! 23 struct mmap_event { 127 u32 flags; !! 24 struct perf_event_header header; 128 }; !! 25 u32 pid, tid; 129 u64 payload; !! 26 u64 start; 130 }; !! 27 u64 len; 131 !! 28 u64 pgoff; 132 struct perf_synth_intel_mwait { !! 29 char filename[PATH_MAX]; 133 u32 padding; !! 30 }; 134 u32 reserved; !! 31 135 union { !! 32 struct comm_event { 136 struct { !! 33 struct perf_event_header header; 137 u64 hints !! 34 u32 pid, tid; 138 reserved1 !! 35 char comm[16]; 139 extensions !! 36 }; 140 reserved2 !! 37 141 }; !! 38 struct fork_event { 142 u64 payload; !! 39 struct perf_event_header header; 143 }; !! 40 u32 pid, ppid; 144 }; !! 41 u32 tid, ptid; 145 !! 42 u64 time; 146 struct perf_synth_intel_pwre { !! 43 }; 147 u32 padding; !! 44 148 u32 reserved; !! 45 struct lost_event { 149 union { !! 46 struct perf_event_header header; 150 struct { !! 47 u64 id; 151 u64 reserved1 !! 48 u64 lost; 152 hw << 153 subcstate << 154 cstate << 155 reserved2 << 156 }; << 157 u64 payload; << 158 }; << 159 }; << 160 << 161 struct perf_synth_intel_exstop { << 162 u32 padding; << 163 union { << 164 struct { << 165 u32 ip << 166 reserved << 167 }; << 168 u32 flags; << 169 }; << 170 }; << 171 << 172 struct perf_synth_intel_pwrx { << 173 u32 padding; << 174 u32 reserved; << 175 union { << 176 struct { << 177 u64 deepest_cstate << 178 last_cstate << 179 wake_reason << 180 reserved1 << 181 }; << 182 u64 payload; << 183 }; << 184 }; << 185 << 186 struct perf_synth_intel_cbr { << 187 u32 padding; << 188 union { << 189 struct { << 190 u32 cbr << 191 reserved1 << 192 max_nonturbo << 193 reserved2 << 194 }; << 195 u32 flags; << 196 }; << 197 u32 freq; << 198 u32 reserved3; << 199 }; << 200 << 201 struct perf_synth_intel_psb { << 202 u32 padding; << 203 u32 reserved; << 204 u64 offset; << 205 }; 49 }; 206 50 207 struct perf_synth_intel_evd { !! 51 /* 208 union { !! 52 * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID 209 struct { !! 53 */ 210 u8 evd_type; !! 54 struct read_event { 211 u8 reserved[7]; !! 55 struct perf_event_header header; 212 }; !! 56 u32 pid, tid; 213 u64 et; !! 57 u64 value; 214 }; !! 58 u64 time_enabled; 215 u64 payload; !! 59 u64 time_running; 216 }; !! 60 u64 id; 217 !! 61 }; 218 /* Intel PT Event Trace */ !! 62 219 struct perf_synth_intel_evt { !! 63 struct sample_event{ 220 u32 padding; !! 64 struct perf_event_header header; 221 union { !! 65 u64 array[]; 222 struct { << 223 u32 type << 224 reserved << 225 ip << 226 vector << 227 evd_cnt << 228 }; << 229 u32 cfe; << 230 }; << 231 struct perf_synth_intel_evd evd[0]; << 232 }; << 233 << 234 struct perf_synth_intel_iflag_chg { << 235 u32 padding; << 236 union { << 237 struct { << 238 u32 iflag << 239 via_branch << 240 }; << 241 u32 flags; << 242 }; << 243 u64 branch_ip; /* If via_branch */ << 244 }; 66 }; 245 67 246 static inline void *perf_synth__raw_data(void << 247 { << 248 return p + 4; << 249 } << 250 << 251 #define perf_synth__raw_size(d) (sizeof(d) - 4 << 252 << 253 #define perf_sample__bad_synth_size(s, d) ((s) << 254 68 255 enum { !! 69 typedef union event_union { 256 PERF_STAT_ROUND_TYPE__INTERVAL = 0, !! 70 struct perf_event_header header; 257 PERF_STAT_ROUND_TYPE__FINAL = 1, !! 71 struct ip_event ip; >> 72 struct mmap_event mmap; >> 73 struct comm_event comm; >> 74 struct fork_event fork; >> 75 struct lost_event lost; >> 76 struct read_event read; >> 77 struct sample_event sample; >> 78 } event_t; >> 79 >> 80 struct map { >> 81 struct list_head node; >> 82 u64 start; >> 83 u64 end; >> 84 u64 pgoff; >> 85 u64 (*map_ip)(struct map *, u64); >> 86 struct dso *dso; 258 }; 87 }; 259 88 260 void perf_event__print_totals(void); !! 89 static inline u64 map__map_ip(struct map *map, u64 ip) 261 << 262 struct perf_cpu_map; << 263 struct perf_record_stat_config; << 264 struct perf_stat_config; << 265 struct perf_tool; << 266 << 267 void perf_event__read_stat_config(struct perf_ << 268 struct perf_ << 269 << 270 int perf_event__process_comm(const struct perf << 271 union perf_event << 272 struct perf_sampl << 273 struct machine *m << 274 int perf_event__process_lost(const struct perf << 275 union perf_event << 276 struct perf_sampl << 277 struct machine *m << 278 int perf_event__process_lost_samples(const str << 279 union per << 280 struct pe << 281 struct ma << 282 int perf_event__process_aux(const struct perf_ << 283 union perf_event * << 284 struct perf_sample << 285 struct machine *ma << 286 int perf_event__process_itrace_start(const str << 287 union per << 288 struct pe << 289 struct ma << 290 int perf_event__process_aux_output_hw_id(const << 291 union << 292 struc << 293 struc << 294 int perf_event__process_switch(const struct pe << 295 union perf_even << 296 struct perf_sam << 297 struct machine << 298 int perf_event__process_namespaces(const struc << 299 union perf_ << 300 struct perf << 301 struct mach << 302 int perf_event__process_cgroup(const struct pe << 303 union perf_even << 304 struct perf_sam << 305 struct machine << 306 int perf_event__process_mmap(const struct perf << 307 union perf_event << 308 struct perf_sampl << 309 struct machine *m << 310 int perf_event__process_mmap2(const struct per << 311 union perf_event << 312 struct perf_sampl << 313 struct machine *m << 314 int perf_event__process_fork(const struct perf << 315 union perf_event << 316 struct perf_sampl << 317 struct machine *m << 318 int perf_event__process_exit(const struct perf << 319 union perf_event << 320 struct perf_sampl << 321 struct machine *m << 322 int perf_event__exit_del_thread(const struct p << 323 union perf_eve << 324 struct perf_sa << 325 struct machine << 326 int perf_event__process_ksymbol(const struct p << 327 union perf_eve << 328 struct perf_sa << 329 struct machine << 330 int perf_event__process_bpf(const struct perf_ << 331 union perf_event * << 332 struct perf_sample << 333 struct machine *ma << 334 int perf_event__process_text_poke(const struct << 335 union perf_e << 336 struct perf_ << 337 struct machi << 338 int perf_event__process(const struct perf_tool << 339 union perf_event *even << 340 struct perf_sample *sa << 341 struct machine *machin << 342 << 343 bool is_bts_event(struct perf_event_attr *attr << 344 bool sample_addr_correlates_sym(struct perf_ev << 345 << 346 const char *perf_event__name(unsigned int id); << 347 << 348 size_t perf_event__fprintf_comm(union perf_eve << 349 size_t perf_event__fprintf_mmap(union perf_eve << 350 size_t perf_event__fprintf_mmap2(union perf_ev << 351 size_t perf_event__fprintf_task(union perf_eve << 352 size_t perf_event__fprintf_aux(union perf_even << 353 size_t perf_event__fprintf_itrace_start(union << 354 size_t perf_event__fprintf_aux_output_hw_id(un << 355 size_t perf_event__fprintf_switch(union perf_e << 356 size_t perf_event__fprintf_thread_map(union pe << 357 size_t perf_event__fprintf_cpu_map(union perf_ << 358 size_t perf_event__fprintf_namespaces(union pe << 359 size_t perf_event__fprintf_cgroup(union perf_e << 360 size_t perf_event__fprintf_ksymbol(union perf_ << 361 size_t perf_event__fprintf_bpf(union perf_even << 362 size_t perf_event__fprintf_text_poke(union per << 363 size_t perf_event__fprintf(union perf_event *e << 364 << 365 int kallsyms__get_function_start(const char *k << 366 const char *s << 367 int kallsyms__get_symbol_start(const char *kal << 368 const char *sym << 369 << 370 void event_attr_init(struct perf_event_attr *a << 371 << 372 int perf_event_paranoid(void); << 373 bool perf_event_paranoid_check(int max_level); << 374 << 375 extern int sysctl_perf_event_max_stack; << 376 extern int sysctl_perf_event_max_contexts_per_ << 377 extern unsigned int proc_map_timeout; << 378 << 379 #define PAGE_SIZE_NAME_LEN 32 << 380 char *get_page_size_name(u64 size, char *str); << 381 << 382 void arch_perf_parse_sample_weight(struct perf << 383 void arch_perf_synthesize_sample_weight(const << 384 const char *arch_perf_header_entry(const char << 385 int arch_support_sort_key(const char *sort_key << 386 << 387 static inline bool perf_event_header__cpumode_ << 388 { 90 { 389 return cpumode == PERF_RECORD_MISC_GUE !! 91 return ip - map->start + map->pgoff; 390 cpumode == PERF_RECORD_MISC_GUE << 391 } 92 } 392 93 393 static inline bool perf_event_header__misc_is_ !! 94 static inline u64 vdso__map_ip(struct map *map __used, u64 ip) 394 { 95 { 395 return perf_event_header__cpumode_is_g !! 96 return ip; 396 } 97 } 397 98 398 static inline bool perf_event_header__is_guest !! 99 struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen); 399 { !! 100 struct map *map__clone(struct map *self); 400 return perf_event_header__misc_is_gues !! 101 int map__overlap(struct map *l, struct map *r); 401 } !! 102 size_t map__fprintf(struct map *self, FILE *fp); 402 103 403 static inline bool perf_event__is_guest(const !! 104 #endif 404 { << 405 return perf_event_header__is_guest(&ev << 406 } << 407 << 408 #endif /* __PERF_RECORD_H */ << 409 105
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.