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