auxtrace.h 22 KB

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