auxtrace.h 22 KB

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