auxtrace.h 22 KB

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