Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 1 | #ifndef __PERF_EVLIST_H |
| 2 | #define __PERF_EVLIST_H 1 |
| 3 | |
| 4 | #include <linux/list.h> |
Arnaldo Carvalho de Melo | 50d08e4 | 2011-11-04 09:10:59 -0200 | [diff] [blame] | 5 | #include <stdio.h> |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 6 | #include "../perf.h" |
Arnaldo Carvalho de Melo | 04391de | 2011-01-15 10:40:59 -0200 | [diff] [blame] | 7 | #include "event.h" |
Arnaldo Carvalho de Melo | 50d08e4 | 2011-11-04 09:10:59 -0200 | [diff] [blame] | 8 | #include "util.h" |
Arnaldo Carvalho de Melo | 35b9d88 | 2011-11-09 08:47:15 -0200 | [diff] [blame] | 9 | #include <unistd.h> |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 10 | |
Arnaldo Carvalho de Melo | 5c58104 | 2011-01-11 22:30:02 -0200 | [diff] [blame] | 11 | struct pollfd; |
Arnaldo Carvalho de Melo | f8a9530 | 2011-01-30 10:46:46 -0200 | [diff] [blame] | 12 | struct thread_map; |
| 13 | struct cpu_map; |
Arnaldo Carvalho de Melo | 0f82ebc | 2011-11-08 14:41:57 -0200 | [diff] [blame] | 14 | struct perf_record_opts; |
Arnaldo Carvalho de Melo | 5c58104 | 2011-01-11 22:30:02 -0200 | [diff] [blame] | 15 | |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 16 | #define PERF_EVLIST__HLIST_BITS 8 |
| 17 | #define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS) |
| 18 | |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 19 | struct perf_evlist { |
| 20 | struct list_head entries; |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 21 | struct hlist_head heads[PERF_EVLIST__HLIST_SIZE]; |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 22 | int nr_entries; |
Arnaldo Carvalho de Melo | 5c58104 | 2011-01-11 22:30:02 -0200 | [diff] [blame] | 23 | int nr_fds; |
Arnaldo Carvalho de Melo | aece948 | 2011-05-15 09:39:00 -0300 | [diff] [blame] | 24 | int nr_mmaps; |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 25 | int mmap_len; |
Arnaldo Carvalho de Melo | 35b9d88 | 2011-11-09 08:47:15 -0200 | [diff] [blame] | 26 | struct { |
| 27 | int cork_fd; |
| 28 | pid_t pid; |
| 29 | } workload; |
Arnaldo Carvalho de Melo | 7bb4115 | 2011-01-29 09:08:13 -0200 | [diff] [blame] | 30 | bool overwrite; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 31 | union perf_event event_copy; |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 32 | struct perf_mmap *mmap; |
Arnaldo Carvalho de Melo | 5c58104 | 2011-01-11 22:30:02 -0200 | [diff] [blame] | 33 | struct pollfd *pollfd; |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 34 | struct thread_map *threads; |
| 35 | struct cpu_map *cpus; |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 36 | struct perf_evsel *selected; |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 37 | }; |
| 38 | |
Arnaldo Carvalho de Melo | ee29be6 | 2011-11-28 17:57:40 -0200 | [diff] [blame] | 39 | struct perf_evsel_str_handler { |
| 40 | const char *name; |
| 41 | void *handler; |
| 42 | }; |
| 43 | |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 44 | struct perf_evsel; |
| 45 | |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 46 | struct perf_evlist *perf_evlist__new(struct cpu_map *cpus, |
| 47 | struct thread_map *threads); |
| 48 | void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus, |
| 49 | struct thread_map *threads); |
Arnaldo Carvalho de Melo | ef1d1af | 2011-01-18 21:41:45 -0200 | [diff] [blame] | 50 | void perf_evlist__exit(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 51 | void perf_evlist__delete(struct perf_evlist *evlist); |
| 52 | |
| 53 | void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry); |
| 54 | int perf_evlist__add_default(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | 50d08e4 | 2011-11-04 09:10:59 -0200 | [diff] [blame] | 55 | int perf_evlist__add_attrs(struct perf_evlist *evlist, |
| 56 | struct perf_event_attr *attrs, size_t nr_attrs); |
Arnaldo Carvalho de Melo | a8c9ae1 | 2011-11-05 08:41:51 -0200 | [diff] [blame] | 57 | int perf_evlist__add_tracepoints(struct perf_evlist *evlist, |
| 58 | const char *tracepoints[], size_t nr_tracepoints); |
Arnaldo Carvalho de Melo | ee29be6 | 2011-11-28 17:57:40 -0200 | [diff] [blame] | 59 | int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist, |
| 60 | const struct perf_evsel_str_handler *assocs, |
| 61 | size_t nr_assocs); |
Arnaldo Carvalho de Melo | 50d08e4 | 2011-11-04 09:10:59 -0200 | [diff] [blame] | 62 | |
| 63 | #define perf_evlist__add_attrs_array(evlist, array) \ |
| 64 | perf_evlist__add_attrs(evlist, array, ARRAY_SIZE(array)) |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 65 | |
Arnaldo Carvalho de Melo | a8c9ae1 | 2011-11-05 08:41:51 -0200 | [diff] [blame] | 66 | #define perf_evlist__add_tracepoints_array(evlist, array) \ |
| 67 | perf_evlist__add_tracepoints(evlist, array, ARRAY_SIZE(array)) |
| 68 | |
Arnaldo Carvalho de Melo | ee29be6 | 2011-11-28 17:57:40 -0200 | [diff] [blame] | 69 | #define perf_evlist__set_tracepoints_handlers_array(evlist, array) \ |
| 70 | perf_evlist__set_tracepoints_handlers(evlist, array, ARRAY_SIZE(array)) |
| 71 | |
Arnaldo Carvalho de Melo | a91e543 | 2011-03-10 11:15:54 -0300 | [diff] [blame] | 72 | void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel, |
| 73 | int cpu, int thread, u64 id); |
Arnaldo Carvalho de Melo | 3d3b5e9 | 2011-03-04 22:29:39 -0300 | [diff] [blame] | 74 | |
Arnaldo Carvalho de Melo | 70082dd | 2011-01-12 17:03:24 -0200 | [diff] [blame] | 75 | void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); |
Arnaldo Carvalho de Melo | 5c58104 | 2011-01-11 22:30:02 -0200 | [diff] [blame] | 76 | |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 77 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); |
| 78 | |
Arnaldo Carvalho de Melo | aece948 | 2011-05-15 09:39:00 -0300 | [diff] [blame] | 79 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx); |
Arnaldo Carvalho de Melo | 04391de | 2011-01-15 10:40:59 -0200 | [diff] [blame] | 80 | |
Arnaldo Carvalho de Melo | 727ab04 | 2011-10-25 10:42:19 -0200 | [diff] [blame] | 81 | int perf_evlist__open(struct perf_evlist *evlist, bool group); |
| 82 | |
Arnaldo Carvalho de Melo | 0f82ebc | 2011-11-08 14:41:57 -0200 | [diff] [blame] | 83 | void perf_evlist__config_attrs(struct perf_evlist *evlist, |
| 84 | struct perf_record_opts *opts); |
| 85 | |
Arnaldo Carvalho de Melo | 35b9d88 | 2011-11-09 08:47:15 -0200 | [diff] [blame] | 86 | int perf_evlist__prepare_workload(struct perf_evlist *evlist, |
| 87 | struct perf_record_opts *opts, |
| 88 | const char *argv[]); |
| 89 | int perf_evlist__start_workload(struct perf_evlist *evlist); |
| 90 | |
Arnaldo Carvalho de Melo | 50a682c | 2011-11-09 09:10:47 -0200 | [diff] [blame] | 91 | int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages, |
| 92 | bool overwrite); |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 93 | void perf_evlist__munmap(struct perf_evlist *evlist); |
| 94 | |
Arnaldo Carvalho de Melo | 4152ab3 | 2011-07-25 11:06:19 -0300 | [diff] [blame] | 95 | void perf_evlist__disable(struct perf_evlist *evlist); |
David Ahern | 764e16a | 2011-08-25 10:17:55 -0600 | [diff] [blame] | 96 | void perf_evlist__enable(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | 4152ab3 | 2011-07-25 11:06:19 -0300 | [diff] [blame] | 97 | |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 98 | void perf_evlist__set_selected(struct perf_evlist *evlist, |
| 99 | struct perf_evsel *evsel); |
| 100 | |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 101 | static inline void perf_evlist__set_maps(struct perf_evlist *evlist, |
| 102 | struct cpu_map *cpus, |
| 103 | struct thread_map *threads) |
| 104 | { |
| 105 | evlist->cpus = cpus; |
| 106 | evlist->threads = threads; |
| 107 | } |
| 108 | |
David Ahern | b52956c | 2012-02-08 09:32:52 -0700 | [diff] [blame] | 109 | int perf_evlist__create_maps(struct perf_evlist *evlist, const char *target_pid, |
| 110 | const char *tid, uid_t uid, const char *cpu_list); |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 111 | void perf_evlist__delete_maps(struct perf_evlist *evlist); |
Frederic Weisbecker | 0a10247 | 2011-02-26 04:51:54 +0100 | [diff] [blame] | 112 | int perf_evlist__set_filters(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | f8a9530 | 2011-01-30 10:46:46 -0200 | [diff] [blame] | 113 | |
Arnaldo Carvalho de Melo | c2a7065 | 2011-06-02 11:04:54 -0300 | [diff] [blame] | 114 | u64 perf_evlist__sample_type(const struct perf_evlist *evlist); |
| 115 | bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | 81e36bf | 2011-11-11 22:28:50 -0200 | [diff] [blame] | 116 | u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist); |
Frederic Weisbecker | 7442996 | 2011-05-21 17:49:00 +0200 | [diff] [blame] | 117 | |
Arnaldo Carvalho de Melo | c2a7065 | 2011-06-02 11:04:54 -0300 | [diff] [blame] | 118 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); |
| 119 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist); |
Jiri Olsa | 0529bc1 | 2012-01-27 15:34:20 +0100 | [diff] [blame] | 120 | |
| 121 | void perf_evlist__splice_list_tail(struct perf_evlist *evlist, |
| 122 | struct list_head *list, |
| 123 | int nr_entries); |
| 124 | |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 125 | #endif /* __PERF_EVLIST_H */ |