auxtrace.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. /*
  2. * auxtrace.h: AUX area trace support
  3. * Copyright (c) 2013-2015, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. */
  15. #ifndef __PERF_AUXTRACE_H
  16. #define __PERF_AUXTRACE_H
  17. #include <sys/types.h>
  18. #include <errno.h>
  19. #include <stdbool.h>
  20. #include <stddef.h>
  21. #include <linux/list.h>
  22. #include <linux/perf_event.h>
  23. #include <linux/types.h>
  24. #include <asm/bitsperlong.h>
  25. #include "../perf.h"
  26. #include "event.h"
  27. #include "session.h"
  28. #include "debug.h"
  29. union perf_event;
  30. struct perf_session;
  31. struct perf_evlist;
  32. struct perf_tool;
  33. struct perf_mmap;
  34. struct option;
  35. struct record_opts;
  36. struct auxtrace_info_event;
  37. struct events_stats;
  38. enum auxtrace_type {
  39. PERF_AUXTRACE_UNKNOWN,
  40. PERF_AUXTRACE_INTEL_PT,
  41. PERF_AUXTRACE_INTEL_BTS,
  42. PERF_AUXTRACE_CS_ETM,
  43. PERF_AUXTRACE_ARM_SPE,
  44. PERF_AUXTRACE_S390_CPUMSF,
  45. };
  46. enum itrace_period_type {
  47. PERF_ITRACE_PERIOD_INSTRUCTIONS,
  48. PERF_ITRACE_PERIOD_TICKS,
  49. PERF_ITRACE_PERIOD_NANOSECS,
  50. };
  51. /**
  52. * struct itrace_synth_opts - AUX area tracing synthesis options.
  53. * @set: indicates whether or not options have been set
  54. * @default_no_sample: Default to no sampling.
  55. * @inject: indicates the event (not just the sample) must be fully synthesized
  56. * because 'perf inject' will write it out
  57. * @instructions: whether to synthesize 'instructions' events
  58. * @branches: whether to synthesize 'branches' events
  59. * @transactions: whether to synthesize events for transactions
  60. * @ptwrites: whether to synthesize events for ptwrites
  61. * @pwr_events: whether to synthesize power events
  62. * @errors: whether to synthesize decoder error events
  63. * @dont_decode: whether to skip decoding entirely
  64. * @log: write a decoding log
  65. * @calls: limit branch samples to calls (can be combined with @returns)
  66. * @returns: limit branch samples to returns (can be combined with @calls)
  67. * @callchain: add callchain to 'instructions' events
  68. * @thread_stack: feed branches to the thread_stack
  69. * @last_branch: add branch context to 'instruction' events
  70. * @callchain_sz: maximum callchain size
  71. * @last_branch_sz: branch context size
  72. * @period: 'instructions' events period
  73. * @period_type: 'instructions' events period type
  74. * @initial_skip: skip N events at the beginning.
  75. * @cpu_bitmap: CPUs for which to synthesize events, or NULL for all
  76. */
  77. struct itrace_synth_opts {
  78. bool set;
  79. bool default_no_sample;
  80. bool inject;
  81. bool instructions;
  82. bool branches;
  83. bool transactions;
  84. bool ptwrites;
  85. bool pwr_events;
  86. bool errors;
  87. bool dont_decode;
  88. bool log;
  89. bool calls;
  90. bool returns;
  91. bool callchain;
  92. bool thread_stack;
  93. bool last_branch;
  94. unsigned int callchain_sz;
  95. unsigned int last_branch_sz;
  96. unsigned long long period;
  97. enum itrace_period_type period_type;
  98. unsigned long initial_skip;
  99. unsigned long *cpu_bitmap;
  100. };
  101. /**
  102. * struct auxtrace_index_entry - indexes a AUX area tracing event within a
  103. * perf.data file.
  104. * @file_offset: offset within the perf.data file
  105. * @sz: size of the event
  106. */
  107. struct auxtrace_index_entry {
  108. u64 file_offset;
  109. u64 sz;
  110. };
  111. #define PERF_AUXTRACE_INDEX_ENTRY_COUNT 256
  112. /**
  113. * struct auxtrace_index - index of AUX area tracing events within a perf.data
  114. * file.
  115. * @list: linking a number of arrays of entries
  116. * @nr: number of entries
  117. * @entries: array of entries
  118. */
  119. struct auxtrace_index {
  120. struct list_head list;
  121. size_t nr;
  122. struct auxtrace_index_entry entries[PERF_AUXTRACE_INDEX_ENTRY_COUNT];
  123. };
  124. /**
  125. * struct auxtrace - session callbacks to allow AUX area data decoding.
  126. * @process_event: lets the decoder see all session events
  127. * @process_auxtrace_event: process a PERF_RECORD_AUXTRACE event
  128. * @flush_events: process any remaining data
  129. * @free_events: free resources associated with event processing
  130. * @free: free resources associated with the session
  131. */
  132. struct auxtrace {
  133. int (*process_event)(struct perf_session *session,
  134. union perf_event *event,
  135. struct perf_sample *sample,
  136. struct perf_tool *tool);
  137. int (*process_auxtrace_event)(struct perf_session *session,
  138. union perf_event *event,
  139. struct perf_tool *tool);
  140. int (*flush_events)(struct perf_session *session,
  141. struct perf_tool *tool);
  142. void (*free_events)(struct perf_session *session);
  143. void (*free)(struct perf_session *session);
  144. };
  145. /**
  146. * struct auxtrace_buffer - a buffer containing AUX area tracing data.
  147. * @list: buffers are queued in a list held by struct auxtrace_queue
  148. * @size: size of the buffer in bytes
  149. * @pid: in per-thread mode, the pid this buffer is associated with
  150. * @tid: in per-thread mode, the tid this buffer is associated with
  151. * @cpu: in per-cpu mode, the cpu this buffer is associated with
  152. * @data: actual buffer data (can be null if the data has not been loaded)
  153. * @data_offset: file offset at which the buffer can be read
  154. * @mmap_addr: mmap address at which the buffer can be read
  155. * @mmap_size: size of the mmap at @mmap_addr
  156. * @data_needs_freeing: @data was malloc'd so free it when it is no longer
  157. * needed
  158. * @consecutive: the original data was split up and this buffer is consecutive
  159. * to the previous buffer
  160. * @offset: offset as determined by aux_head / aux_tail members of struct
  161. * perf_event_mmap_page
  162. * @reference: an implementation-specific reference determined when the data is
  163. * recorded
  164. * @buffer_nr: used to number each buffer
  165. * @use_size: implementation actually only uses this number of bytes
  166. * @use_data: implementation actually only uses data starting at this address
  167. */
  168. struct auxtrace_buffer {
  169. struct list_head list;
  170. size_t size;
  171. pid_t pid;
  172. pid_t tid;
  173. int cpu;
  174. void *data;
  175. off_t data_offset;
  176. void *mmap_addr;
  177. size_t mmap_size;
  178. bool data_needs_freeing;
  179. bool consecutive;
  180. u64 offset;
  181. u64 reference;
  182. u64 buffer_nr;
  183. size_t use_size;
  184. void *use_data;
  185. };
  186. /**
  187. * struct auxtrace_queue - a queue of AUX area tracing data buffers.
  188. * @head: head of buffer list
  189. * @tid: in per-thread mode, the tid this queue is associated with
  190. * @cpu: in per-cpu mode, the cpu this queue is associated with
  191. * @set: %true once this queue has been dedicated to a specific thread or cpu
  192. * @priv: implementation-specific data
  193. */
  194. struct auxtrace_queue {
  195. struct list_head head;
  196. pid_t tid;
  197. int cpu;
  198. bool set;
  199. void *priv;
  200. };
  201. /**
  202. * struct auxtrace_queues - an array of AUX area tracing queues.
  203. * @queue_array: array of queues
  204. * @nr_queues: number of queues
  205. * @new_data: set whenever new data is queued
  206. * @populated: queues have been fully populated using the auxtrace_index
  207. * @next_buffer_nr: used to number each buffer
  208. */
  209. struct auxtrace_queues {
  210. struct auxtrace_queue *queue_array;
  211. unsigned int nr_queues;
  212. bool new_data;
  213. bool populated;
  214. u64 next_buffer_nr;
  215. };
  216. /**
  217. * struct auxtrace_heap_item - element of struct auxtrace_heap.
  218. * @queue_nr: queue number
  219. * @ordinal: value used for sorting (lowest ordinal is top of the heap) expected
  220. * to be a timestamp
  221. */
  222. struct auxtrace_heap_item {
  223. unsigned int queue_nr;
  224. u64 ordinal;
  225. };
  226. /**
  227. * struct auxtrace_heap - a heap suitable for sorting AUX area tracing queues.
  228. * @heap_array: the heap
  229. * @heap_cnt: the number of elements in the heap
  230. * @heap_sz: maximum number of elements (grows as needed)
  231. */
  232. struct auxtrace_heap {
  233. struct auxtrace_heap_item *heap_array;
  234. unsigned int heap_cnt;
  235. unsigned int heap_sz;
  236. };
  237. /**
  238. * struct auxtrace_mmap - records an mmap of the auxtrace buffer.
  239. * @base: address of mapped area
  240. * @userpg: pointer to buffer's perf_event_mmap_page
  241. * @mask: %0 if @len is not a power of two, otherwise (@len - %1)
  242. * @len: size of mapped area
  243. * @prev: previous aux_head
  244. * @idx: index of this mmap
  245. * @tid: tid for a per-thread mmap (also set if there is only 1 tid on a per-cpu
  246. * mmap) otherwise %0
  247. * @cpu: cpu number for a per-cpu mmap otherwise %-1
  248. */
  249. struct auxtrace_mmap {
  250. void *base;
  251. void *userpg;
  252. size_t mask;
  253. size_t len;
  254. u64 prev;
  255. int idx;
  256. pid_t tid;
  257. int cpu;
  258. };
  259. /**
  260. * struct auxtrace_mmap_params - parameters to set up struct auxtrace_mmap.
  261. * @mask: %0 if @len is not a power of two, otherwise (@len - %1)
  262. * @offset: file offset of mapped area
  263. * @len: size of mapped area
  264. * @prot: mmap memory protection
  265. * @idx: index of this mmap
  266. * @tid: tid for a per-thread mmap (also set if there is only 1 tid on a per-cpu
  267. * mmap) otherwise %0
  268. * @cpu: cpu number for a per-cpu mmap otherwise %-1
  269. */
  270. struct auxtrace_mmap_params {
  271. size_t mask;
  272. off_t offset;
  273. size_t len;
  274. int prot;
  275. int idx;
  276. pid_t tid;
  277. int cpu;
  278. };
  279. /**
  280. * struct auxtrace_record - callbacks for recording AUX area data.
  281. * @recording_options: validate and process recording options
  282. * @info_priv_size: return the size of the private data in auxtrace_info_event
  283. * @info_fill: fill-in the private data in auxtrace_info_event
  284. * @free: free this auxtrace record structure
  285. * @snapshot_start: starting a snapshot
  286. * @snapshot_finish: finishing a snapshot
  287. * @find_snapshot: find data to snapshot within auxtrace mmap
  288. * @parse_snapshot_options: parse snapshot options
  289. * @reference: provide a 64-bit reference number for auxtrace_event
  290. * @read_finish: called after reading from an auxtrace mmap
  291. * @alignment: alignment (if any) for AUX area data
  292. */
  293. struct auxtrace_record {
  294. int (*recording_options)(struct auxtrace_record *itr,
  295. struct perf_evlist *evlist,
  296. struct record_opts *opts);
  297. size_t (*info_priv_size)(struct auxtrace_record *itr,
  298. struct perf_evlist *evlist);
  299. int (*info_fill)(struct auxtrace_record *itr,
  300. struct perf_session *session,
  301. struct auxtrace_info_event *auxtrace_info,
  302. size_t priv_size);
  303. void (*free)(struct auxtrace_record *itr);
  304. int (*snapshot_start)(struct auxtrace_record *itr);
  305. int (*snapshot_finish)(struct auxtrace_record *itr);
  306. int (*find_snapshot)(struct auxtrace_record *itr, int idx,
  307. struct auxtrace_mmap *mm, unsigned char *data,
  308. u64 *head, u64 *old);
  309. int (*parse_snapshot_options)(struct auxtrace_record *itr,
  310. struct record_opts *opts,
  311. const char *str);
  312. u64 (*reference)(struct auxtrace_record *itr);
  313. int (*read_finish)(struct auxtrace_record *itr, int idx);
  314. unsigned int alignment;
  315. };
  316. /**
  317. * struct addr_filter - address filter.
  318. * @list: list node
  319. * @range: true if it is a range filter
  320. * @start: true if action is 'filter' or 'start'
  321. * @action: 'filter', 'start' or 'stop' ('tracestop' is accepted but converted
  322. * to 'stop')
  323. * @sym_from: symbol name for the filter address
  324. * @sym_to: symbol name that determines the filter size
  325. * @sym_from_idx: selects n'th from symbols with the same name (0 means global
  326. * and less than 0 means symbol must be unique)
  327. * @sym_to_idx: same as @sym_from_idx but for @sym_to
  328. * @addr: filter address
  329. * @size: filter region size (for range filters)
  330. * @filename: DSO file name or NULL for the kernel
  331. * @str: allocated string that contains the other string members
  332. */
  333. struct addr_filter {
  334. struct list_head list;
  335. bool range;
  336. bool start;
  337. const char *action;
  338. const char *sym_from;
  339. const char *sym_to;
  340. int sym_from_idx;
  341. int sym_to_idx;
  342. u64 addr;
  343. u64 size;
  344. const char *filename;
  345. char *str;
  346. };
  347. /**
  348. * struct addr_filters - list of address filters.
  349. * @head: list of address filters
  350. * @cnt: number of address filters
  351. */
  352. struct addr_filters {
  353. struct list_head head;
  354. int cnt;
  355. };
  356. #ifdef HAVE_AUXTRACE_SUPPORT
  357. /*
  358. * In snapshot mode the mmapped page is read-only which makes using
  359. * __sync_val_compare_and_swap() problematic. However, snapshot mode expects
  360. * the buffer is not updated while the snapshot is made (e.g. Intel PT disables
  361. * the event) so there is not a race anyway.
  362. */
  363. static inline u64 auxtrace_mmap__read_snapshot_head(struct auxtrace_mmap *mm)
  364. {
  365. struct perf_event_mmap_page *pc = mm->userpg;
  366. u64 head = READ_ONCE(pc->aux_head);
  367. /* Ensure all reads are done after we read the head */
  368. rmb();
  369. return head;
  370. }
  371. static inline u64 auxtrace_mmap__read_head(struct auxtrace_mmap *mm)
  372. {
  373. struct perf_event_mmap_page *pc = mm->userpg;
  374. #if BITS_PER_LONG == 64 || !defined(HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT)
  375. u64 head = READ_ONCE(pc->aux_head);
  376. #else
  377. u64 head = __sync_val_compare_and_swap(&pc->aux_head, 0, 0);
  378. #endif
  379. /* Ensure all reads are done after we read the head */
  380. rmb();
  381. return head;
  382. }
  383. static inline void auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail)
  384. {
  385. struct perf_event_mmap_page *pc = mm->userpg;
  386. #if BITS_PER_LONG != 64 && defined(HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT)
  387. u64 old_tail;
  388. #endif
  389. /* Ensure all reads are done before we write the tail out */
  390. mb();
  391. #if BITS_PER_LONG == 64 || !defined(HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT)
  392. pc->aux_tail = tail;
  393. #else
  394. do {
  395. old_tail = __sync_val_compare_and_swap(&pc->aux_tail, 0, 0);
  396. } while (!__sync_bool_compare_and_swap(&pc->aux_tail, old_tail, tail));
  397. #endif
  398. }
  399. int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
  400. struct auxtrace_mmap_params *mp,
  401. void *userpg, int fd);
  402. void auxtrace_mmap__munmap(struct auxtrace_mmap *mm);
  403. void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp,
  404. off_t auxtrace_offset,
  405. unsigned int auxtrace_pages,
  406. bool auxtrace_overwrite);
  407. void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
  408. struct perf_evlist *evlist, int idx,
  409. bool per_cpu);
  410. typedef int (*process_auxtrace_t)(struct perf_tool *tool,
  411. struct perf_mmap *map,
  412. union perf_event *event, void *data1,
  413. size_t len1, void *data2, size_t len2);
  414. int auxtrace_mmap__read(struct perf_mmap *map, struct auxtrace_record *itr,
  415. struct perf_tool *tool, process_auxtrace_t fn);
  416. int auxtrace_mmap__read_snapshot(struct perf_mmap *map,
  417. struct auxtrace_record *itr,
  418. struct perf_tool *tool, process_auxtrace_t fn,
  419. size_t snapshot_size);
  420. int auxtrace_queues__init(struct auxtrace_queues *queues);
  421. int auxtrace_queues__add_event(struct auxtrace_queues *queues,
  422. struct perf_session *session,
  423. union perf_event *event, off_t data_offset,
  424. struct auxtrace_buffer **buffer_ptr);
  425. void auxtrace_queues__free(struct auxtrace_queues *queues);
  426. int auxtrace_queues__process_index(struct auxtrace_queues *queues,
  427. struct perf_session *session);
  428. struct auxtrace_buffer *auxtrace_buffer__next(struct auxtrace_queue *queue,
  429. struct auxtrace_buffer *buffer);
  430. void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd);
  431. void auxtrace_buffer__put_data(struct auxtrace_buffer *buffer);
  432. void auxtrace_buffer__drop_data(struct auxtrace_buffer *buffer);
  433. void auxtrace_buffer__free(struct auxtrace_buffer *buffer);
  434. int auxtrace_heap__add(struct auxtrace_heap *heap, unsigned int queue_nr,
  435. u64 ordinal);
  436. void auxtrace_heap__pop(struct auxtrace_heap *heap);
  437. void auxtrace_heap__free(struct auxtrace_heap *heap);
  438. struct auxtrace_cache_entry {
  439. struct hlist_node hash;
  440. u32 key;
  441. };
  442. struct auxtrace_cache *auxtrace_cache__new(unsigned int bits, size_t entry_size,
  443. unsigned int limit_percent);
  444. void auxtrace_cache__free(struct auxtrace_cache *auxtrace_cache);
  445. void *auxtrace_cache__alloc_entry(struct auxtrace_cache *c);
  446. void auxtrace_cache__free_entry(struct auxtrace_cache *c, void *entry);
  447. int auxtrace_cache__add(struct auxtrace_cache *c, u32 key,
  448. struct auxtrace_cache_entry *entry);
  449. void *auxtrace_cache__lookup(struct auxtrace_cache *c, u32 key);
  450. struct auxtrace_record *auxtrace_record__init(struct perf_evlist *evlist,
  451. int *err);
  452. int auxtrace_parse_snapshot_options(struct auxtrace_record *itr,
  453. struct record_opts *opts,
  454. const char *str);
  455. int auxtrace_record__options(struct auxtrace_record *itr,
  456. struct perf_evlist *evlist,
  457. struct record_opts *opts);
  458. size_t auxtrace_record__info_priv_size(struct auxtrace_record *itr,
  459. struct perf_evlist *evlist);
  460. int auxtrace_record__info_fill(struct auxtrace_record *itr,
  461. struct perf_session *session,
  462. struct auxtrace_info_event *auxtrace_info,
  463. size_t priv_size);
  464. void auxtrace_record__free(struct auxtrace_record *itr);
  465. int auxtrace_record__snapshot_start(struct auxtrace_record *itr);
  466. int auxtrace_record__snapshot_finish(struct auxtrace_record *itr);
  467. int auxtrace_record__find_snapshot(struct auxtrace_record *itr, int idx,
  468. struct auxtrace_mmap *mm,
  469. unsigned char *data, u64 *head, u64 *old);
  470. u64 auxtrace_record__reference(struct auxtrace_record *itr);
  471. int auxtrace_index__auxtrace_event(struct list_head *head, union perf_event *event,
  472. off_t file_offset);
  473. int auxtrace_index__write(int fd, struct list_head *head);
  474. int auxtrace_index__process(int fd, u64 size, struct perf_session *session,
  475. bool needs_swap);
  476. void auxtrace_index__free(struct list_head *head);
  477. void auxtrace_synth_error(struct auxtrace_error_event *auxtrace_error, int type,
  478. int code, int cpu, pid_t pid, pid_t tid, u64 ip,
  479. const char *msg);
  480. int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
  481. struct perf_tool *tool,
  482. struct perf_session *session,
  483. perf_event__handler_t process);
  484. int perf_event__process_auxtrace_info(struct perf_session *session,
  485. union perf_event *event);
  486. s64 perf_event__process_auxtrace(struct perf_session *session,
  487. union perf_event *event);
  488. int perf_event__process_auxtrace_error(struct perf_session *session,
  489. union perf_event *event);
  490. int itrace_parse_synth_opts(const struct option *opt, const char *str,
  491. int unset);
  492. void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts,
  493. bool no_sample);
  494. size_t perf_event__fprintf_auxtrace_error(union perf_event *event, FILE *fp);
  495. void perf_session__auxtrace_error_inc(struct perf_session *session,
  496. union perf_event *event);
  497. void events_stats__auxtrace_error_warn(const struct events_stats *stats);
  498. void addr_filters__init(struct addr_filters *filts);
  499. void addr_filters__exit(struct addr_filters *filts);
  500. int addr_filters__parse_bare_filter(struct addr_filters *filts,
  501. const char *filter);
  502. int auxtrace_parse_filters(struct perf_evlist *evlist);
  503. static inline int auxtrace__process_event(struct perf_session *session,
  504. union perf_event *event,
  505. struct perf_sample *sample,
  506. struct perf_tool *tool)
  507. {
  508. if (!session->auxtrace)
  509. return 0;
  510. return session->auxtrace->process_event(session, event, sample, tool);
  511. }
  512. static inline int auxtrace__flush_events(struct perf_session *session,
  513. struct perf_tool *tool)
  514. {
  515. if (!session->auxtrace)
  516. return 0;
  517. return session->auxtrace->flush_events(session, tool);
  518. }
  519. static inline void auxtrace__free_events(struct perf_session *session)
  520. {
  521. if (!session->auxtrace)
  522. return;
  523. return session->auxtrace->free_events(session);
  524. }
  525. static inline void auxtrace__free(struct perf_session *session)
  526. {
  527. if (!session->auxtrace)
  528. return;
  529. return session->auxtrace->free(session);
  530. }
  531. #define ITRACE_HELP \
  532. " i: synthesize instructions events\n" \
  533. " b: synthesize branches events\n" \
  534. " c: synthesize branches events (calls only)\n" \
  535. " r: synthesize branches events (returns only)\n" \
  536. " x: synthesize transactions events\n" \
  537. " w: synthesize ptwrite events\n" \
  538. " p: synthesize power events\n" \
  539. " e: synthesize error events\n" \
  540. " d: create a debug log\n" \
  541. " g[len]: synthesize a call chain (use with i or x)\n" \
  542. " l[len]: synthesize last branch entries (use with i or x)\n" \
  543. " sNUMBER: skip initial number of events\n" \
  544. " PERIOD[ns|us|ms|i|t]: specify period to sample stream\n" \
  545. " concatenate multiple options. Default is ibxwpe or cewp\n"
  546. #else
  547. static inline struct auxtrace_record *
  548. auxtrace_record__init(struct perf_evlist *evlist __maybe_unused,
  549. int *err)
  550. {
  551. *err = 0;
  552. return NULL;
  553. }
  554. static inline
  555. void auxtrace_record__free(struct auxtrace_record *itr __maybe_unused)
  556. {
  557. }
  558. static inline int
  559. perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_unused,
  560. struct perf_tool *tool __maybe_unused,
  561. struct perf_session *session __maybe_unused,
  562. perf_event__handler_t process __maybe_unused)
  563. {
  564. return -EINVAL;
  565. }
  566. static inline
  567. int auxtrace_record__options(struct auxtrace_record *itr __maybe_unused,
  568. struct perf_evlist *evlist __maybe_unused,
  569. struct record_opts *opts __maybe_unused)
  570. {
  571. return 0;
  572. }
  573. #define perf_event__process_auxtrace_info 0
  574. #define perf_event__process_auxtrace 0
  575. #define perf_event__process_auxtrace_error 0
  576. static inline
  577. void perf_session__auxtrace_error_inc(struct perf_session *session
  578. __maybe_unused,
  579. union perf_event *event
  580. __maybe_unused)
  581. {
  582. }
  583. static inline
  584. void events_stats__auxtrace_error_warn(const struct events_stats *stats
  585. __maybe_unused)
  586. {
  587. }
  588. static inline
  589. int itrace_parse_synth_opts(const struct option *opt __maybe_unused,
  590. const char *str __maybe_unused,
  591. int unset __maybe_unused)
  592. {
  593. pr_err("AUX area tracing not supported\n");
  594. return -EINVAL;
  595. }
  596. static inline
  597. int auxtrace_parse_snapshot_options(struct auxtrace_record *itr __maybe_unused,
  598. struct record_opts *opts __maybe_unused,
  599. const char *str)
  600. {
  601. if (!str)
  602. return 0;
  603. pr_err("AUX area tracing not supported\n");
  604. return -EINVAL;
  605. }
  606. static inline
  607. int auxtrace__process_event(struct perf_session *session __maybe_unused,
  608. union perf_event *event __maybe_unused,
  609. struct perf_sample *sample __maybe_unused,
  610. struct perf_tool *tool __maybe_unused)
  611. {
  612. return 0;
  613. }
  614. static inline
  615. int auxtrace__flush_events(struct perf_session *session __maybe_unused,
  616. struct perf_tool *tool __maybe_unused)
  617. {
  618. return 0;
  619. }
  620. static inline
  621. void auxtrace__free_events(struct perf_session *session __maybe_unused)
  622. {
  623. }
  624. static inline
  625. void auxtrace_cache__free(struct auxtrace_cache *auxtrace_cache __maybe_unused)
  626. {
  627. }
  628. static inline
  629. void auxtrace__free(struct perf_session *session __maybe_unused)
  630. {
  631. }
  632. static inline
  633. int auxtrace_index__write(int fd __maybe_unused,
  634. struct list_head *head __maybe_unused)
  635. {
  636. return -EINVAL;
  637. }
  638. static inline
  639. int auxtrace_index__process(int fd __maybe_unused,
  640. u64 size __maybe_unused,
  641. struct perf_session *session __maybe_unused,
  642. bool needs_swap __maybe_unused)
  643. {
  644. return -EINVAL;
  645. }
  646. static inline
  647. void auxtrace_index__free(struct list_head *head __maybe_unused)
  648. {
  649. }
  650. static inline
  651. int auxtrace_parse_filters(struct perf_evlist *evlist __maybe_unused)
  652. {
  653. return 0;
  654. }
  655. int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
  656. struct auxtrace_mmap_params *mp,
  657. void *userpg, int fd);
  658. void auxtrace_mmap__munmap(struct auxtrace_mmap *mm);
  659. void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp,
  660. off_t auxtrace_offset,
  661. unsigned int auxtrace_pages,
  662. bool auxtrace_overwrite);
  663. void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
  664. struct perf_evlist *evlist, int idx,
  665. bool per_cpu);
  666. #define ITRACE_HELP ""
  667. #endif
  668. #endif