blob: 56003f779e601d181eec34fd38de5bb66c30bc5c [file] [log] [blame]
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -02001#ifndef __PERF_EVLIST_H
2#define __PERF_EVLIST_H 1
3
4#include <linux/list.h>
Arnaldo Carvalho de Melo50d08e42011-11-04 09:10:59 -02005#include <stdio.h>
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -02006#include "../perf.h"
Arnaldo Carvalho de Melo04391de2011-01-15 10:40:59 -02007#include "event.h"
Arnaldo Carvalho de Melo0c21f732012-08-14 16:42:15 -03008#include "evsel.h"
Arnaldo Carvalho de Melo50d08e42011-11-04 09:10:59 -02009#include "util.h"
Arnaldo Carvalho de Melo35b9d882011-11-09 08:47:15 -020010#include <unistd.h>
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020011
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020012struct pollfd;
Arnaldo Carvalho de Melof8a95302011-01-30 10:46:46 -020013struct thread_map;
14struct cpu_map;
Arnaldo Carvalho de Melo0f82ebc2011-11-08 14:41:57 -020015struct perf_record_opts;
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020016
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020017#define PERF_EVLIST__HLIST_BITS 8
18#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
19
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020020struct perf_evlist {
21 struct list_head entries;
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020022 struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020023 int nr_entries;
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020024 int nr_fds;
Arnaldo Carvalho de Meloaece9482011-05-15 09:39:00 -030025 int nr_mmaps;
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020026 int mmap_len;
Arnaldo Carvalho de Melo35b9d882011-11-09 08:47:15 -020027 struct {
28 int cork_fd;
29 pid_t pid;
30 } workload;
Arnaldo Carvalho de Melo7bb41152011-01-29 09:08:13 -020031 bool overwrite;
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -020032 union perf_event event_copy;
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020033 struct perf_mmap *mmap;
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020034 struct pollfd *pollfd;
Arnaldo Carvalho de Melo7e2ed092011-01-30 11:59:43 -020035 struct thread_map *threads;
36 struct cpu_map *cpus;
Arnaldo Carvalho de Melo81cce8d2011-10-05 19:11:32 -030037 struct perf_evsel *selected;
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020038};
39
Arnaldo Carvalho de Meloee29be62011-11-28 17:57:40 -020040struct perf_evsel_str_handler {
41 const char *name;
42 void *handler;
43};
44
Arnaldo Carvalho de Melo7e2ed092011-01-30 11:59:43 -020045struct perf_evlist *perf_evlist__new(struct cpu_map *cpus,
46 struct thread_map *threads);
47void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
48 struct thread_map *threads);
Arnaldo Carvalho de Meloef1d1af2011-01-18 21:41:45 -020049void perf_evlist__exit(struct perf_evlist *evlist);
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020050void perf_evlist__delete(struct perf_evlist *evlist);
51
52void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
53int perf_evlist__add_default(struct perf_evlist *evlist);
Arnaldo Carvalho de Melo79695e12012-05-30 13:53:54 -030054int __perf_evlist__add_default_attrs(struct perf_evlist *evlist,
55 struct perf_event_attr *attrs, size_t nr_attrs);
Arnaldo Carvalho de Melo50d08e42011-11-04 09:10:59 -020056
Arnaldo Carvalho de Melo79695e12012-05-30 13:53:54 -030057#define perf_evlist__add_default_attrs(evlist, array) \
58 __perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020059
Arnaldo Carvalho de Melo39876e72012-10-03 11:40:22 -030060int perf_evlist__add_newtp(struct perf_evlist *evlist,
61 const char *sys, const char *name, void *handler);
62
Arnaldo Carvalho de Melo745cefc2012-09-26 15:07:39 -030063int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter);
64
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030065struct perf_evsel *
66perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id);
67
Arnaldo Carvalho de Meloa91e5432011-03-10 11:15:54 -030068void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
69 int cpu, int thread, u64 id);
Arnaldo Carvalho de Melo3d3b5e92011-03-04 22:29:39 -030070
Arnaldo Carvalho de Melo70082dd2011-01-12 17:03:24 -020071void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020072
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020073struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
74
Arnaldo Carvalho de Meloaece9482011-05-15 09:39:00 -030075union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
Arnaldo Carvalho de Melo04391de2011-01-15 10:40:59 -020076
Jiri Olsa6a4bb042012-08-08 12:22:36 +020077int perf_evlist__open(struct perf_evlist *evlist);
Arnaldo Carvalho de Melo727ab042011-10-25 10:42:19 -020078
Arnaldo Carvalho de Melo0f82ebc2011-11-08 14:41:57 -020079void perf_evlist__config_attrs(struct perf_evlist *evlist,
80 struct perf_record_opts *opts);
81
Arnaldo Carvalho de Melo35b9d882011-11-09 08:47:15 -020082int perf_evlist__prepare_workload(struct perf_evlist *evlist,
83 struct perf_record_opts *opts,
84 const char *argv[]);
85int perf_evlist__start_workload(struct perf_evlist *evlist);
86
Arnaldo Carvalho de Melo50a682c2011-11-09 09:10:47 -020087int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
88 bool overwrite);
Arnaldo Carvalho de Melo7e2ed092011-01-30 11:59:43 -020089void perf_evlist__munmap(struct perf_evlist *evlist);
90
Arnaldo Carvalho de Melo4152ab32011-07-25 11:06:19 -030091void perf_evlist__disable(struct perf_evlist *evlist);
David Ahern764e16a32011-08-25 10:17:55 -060092void perf_evlist__enable(struct perf_evlist *evlist);
Arnaldo Carvalho de Melo4152ab32011-07-25 11:06:19 -030093
Arnaldo Carvalho de Melo81cce8d2011-10-05 19:11:32 -030094void perf_evlist__set_selected(struct perf_evlist *evlist,
95 struct perf_evsel *evsel);
96
Arnaldo Carvalho de Melo7e2ed092011-01-30 11:59:43 -020097static 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 Kimb809ac12012-04-26 14:15:19 +0900105int perf_evlist__create_maps(struct perf_evlist *evlist,
106 struct perf_target *target);
Arnaldo Carvalho de Melo7e2ed092011-01-30 11:59:43 -0200107void perf_evlist__delete_maps(struct perf_evlist *evlist);
Arnaldo Carvalho de Melo1491a632012-09-26 14:43:13 -0300108int perf_evlist__apply_filters(struct perf_evlist *evlist);
Arnaldo Carvalho de Melof8a95302011-01-30 10:46:46 -0200109
Arnaldo Carvalho de Melo63dab222012-08-14 16:35:48 -0300110void __perf_evlist__set_leader(struct list_head *list);
111void perf_evlist__set_leader(struct perf_evlist *evlist);
112
Arnaldo Carvalho de Melo0c21f732012-08-14 16:42:15 -0300113u64 perf_evlist__sample_type(struct perf_evlist *evlist);
114bool perf_evlist__sample_id_all(struct perf_evlist *evlist);
115u16 perf_evlist__id_hdr_size(struct perf_evlist *evlist);
Frederic Weisbecker74429962011-05-21 17:49:00 +0200116
Arnaldo Carvalho de Meloa3f698f2012-08-02 12:23:46 -0300117int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event,
Arnaldo Carvalho de Melo0807d2d2012-09-26 12:48:18 -0300118 struct perf_sample *sample);
Arnaldo Carvalho de Melocb0b29e2012-08-02 11:42:57 -0300119
Arnaldo Carvalho de Melo0c21f732012-08-14 16:42:15 -0300120bool perf_evlist__valid_sample_type(struct perf_evlist *evlist);
121bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist);
Jiri Olsa0529bc12012-01-27 15:34:20 +0100122
123void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
124 struct list_head *list,
125 int nr_entries);
Arnaldo Carvalho de Melo0c21f732012-08-14 16:42:15 -0300126
127static 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
132static 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 Melo78f067b2012-09-06 14:54:11 -0300136
137size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -0200138#endif /* __PERF_EVLIST_H */