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 | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 8 | #include "evsel.h" |
Arnaldo Carvalho de Melo | 50d08e4 | 2011-11-04 09:10:59 -0200 | [diff] [blame] | 9 | #include "util.h" |
Arnaldo Carvalho de Melo | 35b9d88 | 2011-11-09 08:47:15 -0200 | [diff] [blame] | 10 | #include <unistd.h> |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 11 | |
Arnaldo Carvalho de Melo | 5c58104 | 2011-01-11 22:30:02 -0200 | [diff] [blame] | 12 | struct pollfd; |
Arnaldo Carvalho de Melo | f8a9530 | 2011-01-30 10:46:46 -0200 | [diff] [blame] | 13 | struct thread_map; |
| 14 | struct cpu_map; |
Arnaldo Carvalho de Melo | 0f82ebc | 2011-11-08 14:41:57 -0200 | [diff] [blame] | 15 | struct perf_record_opts; |
Arnaldo Carvalho de Melo | 5c58104 | 2011-01-11 22:30:02 -0200 | [diff] [blame] | 16 | |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 17 | #define PERF_EVLIST__HLIST_BITS 8 |
| 18 | #define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS) |
| 19 | |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 20 | struct perf_evlist { |
| 21 | struct list_head entries; |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 22 | struct hlist_head heads[PERF_EVLIST__HLIST_SIZE]; |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 23 | int nr_entries; |
Arnaldo Carvalho de Melo | 5c58104 | 2011-01-11 22:30:02 -0200 | [diff] [blame] | 24 | int nr_fds; |
Arnaldo Carvalho de Melo | aece948 | 2011-05-15 09:39:00 -0300 | [diff] [blame] | 25 | int nr_mmaps; |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 26 | int mmap_len; |
Arnaldo Carvalho de Melo | 35b9d88 | 2011-11-09 08:47:15 -0200 | [diff] [blame] | 27 | struct { |
| 28 | int cork_fd; |
| 29 | pid_t pid; |
| 30 | } workload; |
Arnaldo Carvalho de Melo | 7bb4115 | 2011-01-29 09:08:13 -0200 | [diff] [blame] | 31 | bool overwrite; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 32 | union perf_event event_copy; |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 33 | struct perf_mmap *mmap; |
Arnaldo Carvalho de Melo | 5c58104 | 2011-01-11 22:30:02 -0200 | [diff] [blame] | 34 | struct pollfd *pollfd; |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 35 | struct thread_map *threads; |
| 36 | struct cpu_map *cpus; |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 37 | struct perf_evsel *selected; |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 38 | }; |
| 39 | |
Arnaldo Carvalho de Melo | ee29be6 | 2011-11-28 17:57:40 -0200 | [diff] [blame] | 40 | struct perf_evsel_str_handler { |
| 41 | const char *name; |
| 42 | void *handler; |
| 43 | }; |
| 44 | |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 45 | struct perf_evlist *perf_evlist__new(struct cpu_map *cpus, |
| 46 | struct thread_map *threads); |
| 47 | void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus, |
| 48 | struct thread_map *threads); |
Arnaldo Carvalho de Melo | ef1d1af | 2011-01-18 21:41:45 -0200 | [diff] [blame] | 49 | void perf_evlist__exit(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 50 | void perf_evlist__delete(struct perf_evlist *evlist); |
| 51 | |
| 52 | void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry); |
| 53 | int perf_evlist__add_default(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | 79695e1 | 2012-05-30 13:53:54 -0300 | [diff] [blame] | 54 | int __perf_evlist__add_default_attrs(struct perf_evlist *evlist, |
| 55 | struct perf_event_attr *attrs, size_t nr_attrs); |
Arnaldo Carvalho de Melo | 50d08e4 | 2011-11-04 09:10:59 -0200 | [diff] [blame] | 56 | |
Arnaldo Carvalho de Melo | 79695e1 | 2012-05-30 13:53:54 -0300 | [diff] [blame] | 57 | #define perf_evlist__add_default_attrs(evlist, array) \ |
| 58 | __perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array)) |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 59 | |
Arnaldo Carvalho de Melo | 39876e7 | 2012-10-03 11:40:22 -0300 | [diff] [blame] | 60 | int perf_evlist__add_newtp(struct perf_evlist *evlist, |
| 61 | const char *sys, const char *name, void *handler); |
| 62 | |
Arnaldo Carvalho de Melo | 745cefc | 2012-09-26 15:07:39 -0300 | [diff] [blame] | 63 | int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter); |
| 64 | |
Arnaldo Carvalho de Melo | da37896 | 2012-06-27 13:08:42 -0300 | [diff] [blame] | 65 | struct perf_evsel * |
| 66 | perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id); |
| 67 | |
Arnaldo Carvalho de Melo | a91e543 | 2011-03-10 11:15:54 -0300 | [diff] [blame] | 68 | void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel, |
| 69 | int cpu, int thread, u64 id); |
Arnaldo Carvalho de Melo | 3d3b5e9 | 2011-03-04 22:29:39 -0300 | [diff] [blame] | 70 | |
Arnaldo Carvalho de Melo | 70082dd | 2011-01-12 17:03:24 -0200 | [diff] [blame] | 71 | 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] | 72 | |
Arnaldo Carvalho de Melo | 70db753 | 2011-01-12 22:39:13 -0200 | [diff] [blame] | 73 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); |
| 74 | |
Arnaldo Carvalho de Melo | aece948 | 2011-05-15 09:39:00 -0300 | [diff] [blame] | 75 | 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] | 76 | |
Jiri Olsa | 6a4bb04 | 2012-08-08 12:22:36 +0200 | [diff] [blame] | 77 | int perf_evlist__open(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | 727ab04 | 2011-10-25 10:42:19 -0200 | [diff] [blame] | 78 | |
Arnaldo Carvalho de Melo | 0f82ebc | 2011-11-08 14:41:57 -0200 | [diff] [blame] | 79 | void perf_evlist__config_attrs(struct perf_evlist *evlist, |
| 80 | struct perf_record_opts *opts); |
| 81 | |
Arnaldo Carvalho de Melo | 35b9d88 | 2011-11-09 08:47:15 -0200 | [diff] [blame] | 82 | int perf_evlist__prepare_workload(struct perf_evlist *evlist, |
| 83 | struct perf_record_opts *opts, |
| 84 | const char *argv[]); |
| 85 | int perf_evlist__start_workload(struct perf_evlist *evlist); |
| 86 | |
Arnaldo Carvalho de Melo | 50a682c | 2011-11-09 09:10:47 -0200 | [diff] [blame] | 87 | int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages, |
| 88 | bool overwrite); |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 89 | void perf_evlist__munmap(struct perf_evlist *evlist); |
| 90 | |
Arnaldo Carvalho de Melo | 4152ab3 | 2011-07-25 11:06:19 -0300 | [diff] [blame] | 91 | void perf_evlist__disable(struct perf_evlist *evlist); |
David Ahern | 764e16a3 | 2011-08-25 10:17:55 -0600 | [diff] [blame] | 92 | void perf_evlist__enable(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | 4152ab3 | 2011-07-25 11:06:19 -0300 | [diff] [blame] | 93 | |
Arnaldo Carvalho de Melo | 81cce8d | 2011-10-05 19:11:32 -0300 | [diff] [blame] | 94 | void perf_evlist__set_selected(struct perf_evlist *evlist, |
| 95 | struct perf_evsel *evsel); |
| 96 | |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 97 | static inline void perf_evlist__set_maps(struct perf_evlist *evlist, |
| 98 | struct cpu_map *cpus, |
| 99 | struct thread_map *threads) |
| 100 | { |
| 101 | evlist->cpus = cpus; |
| 102 | evlist->threads = threads; |
| 103 | } |
| 104 | |
Namhyung Kim | b809ac1 | 2012-04-26 14:15:19 +0900 | [diff] [blame] | 105 | int perf_evlist__create_maps(struct perf_evlist *evlist, |
| 106 | struct perf_target *target); |
Arnaldo Carvalho de Melo | 7e2ed09 | 2011-01-30 11:59:43 -0200 | [diff] [blame] | 107 | void perf_evlist__delete_maps(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | 1491a63 | 2012-09-26 14:43:13 -0300 | [diff] [blame] | 108 | int perf_evlist__apply_filters(struct perf_evlist *evlist); |
Arnaldo Carvalho de Melo | f8a9530 | 2011-01-30 10:46:46 -0200 | [diff] [blame] | 109 | |
Arnaldo Carvalho de Melo | 63dab22 | 2012-08-14 16:35:48 -0300 | [diff] [blame] | 110 | void __perf_evlist__set_leader(struct list_head *list); |
| 111 | void perf_evlist__set_leader(struct perf_evlist *evlist); |
| 112 | |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 113 | u64 perf_evlist__sample_type(struct perf_evlist *evlist); |
| 114 | bool perf_evlist__sample_id_all(struct perf_evlist *evlist); |
| 115 | u16 perf_evlist__id_hdr_size(struct perf_evlist *evlist); |
Frederic Weisbecker | 7442996 | 2011-05-21 17:49:00 +0200 | [diff] [blame] | 116 | |
Arnaldo Carvalho de Melo | a3f698f | 2012-08-02 12:23:46 -0300 | [diff] [blame] | 117 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, |
Arnaldo Carvalho de Melo | 0807d2d | 2012-09-26 12:48:18 -0300 | [diff] [blame] | 118 | struct perf_sample *sample); |
Arnaldo Carvalho de Melo | cb0b29e | 2012-08-02 11:42:57 -0300 | [diff] [blame] | 119 | |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 120 | bool perf_evlist__valid_sample_type(struct perf_evlist *evlist); |
| 121 | bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist); |
Jiri Olsa | 0529bc1 | 2012-01-27 15:34:20 +0100 | [diff] [blame] | 122 | |
| 123 | void perf_evlist__splice_list_tail(struct perf_evlist *evlist, |
| 124 | struct list_head *list, |
| 125 | int nr_entries); |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 126 | |
| 127 | static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist) |
| 128 | { |
| 129 | return list_entry(evlist->entries.next, struct perf_evsel, node); |
| 130 | } |
| 131 | |
| 132 | static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist) |
| 133 | { |
| 134 | return list_entry(evlist->entries.prev, struct perf_evsel, node); |
| 135 | } |
Arnaldo Carvalho de Melo | 78f067b | 2012-09-06 14:54:11 -0300 | [diff] [blame] | 136 | |
| 137 | size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp); |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 138 | #endif /* __PERF_EVLIST_H */ |