blob: 21f1c9e57f13900efff43dc72f962c1902ddd69e [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 Melo50d08e42011-11-04 09:10:59 -02008#include "util.h"
Arnaldo Carvalho de Melo35b9d882011-11-09 08:47:15 -02009#include <unistd.h>
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020010
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020011struct pollfd;
Arnaldo Carvalho de Melof8a95302011-01-30 10:46:46 -020012struct thread_map;
13struct cpu_map;
Arnaldo Carvalho de Melo0f82ebc2011-11-08 14:41:57 -020014struct perf_record_opts;
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020015
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020016#define PERF_EVLIST__HLIST_BITS 8
17#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
18
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020019struct perf_evlist {
20 struct list_head entries;
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020021 struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020022 int nr_entries;
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020023 int nr_fds;
Arnaldo Carvalho de Meloaece9482011-05-15 09:39:00 -030024 int nr_mmaps;
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020025 int mmap_len;
Arnaldo Carvalho de Melo35b9d882011-11-09 08:47:15 -020026 struct {
27 int cork_fd;
28 pid_t pid;
29 } workload;
Arnaldo Carvalho de Melo7bb41152011-01-29 09:08:13 -020030 bool overwrite;
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -020031 union perf_event event_copy;
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020032 struct perf_mmap *mmap;
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020033 struct pollfd *pollfd;
Arnaldo Carvalho de Melo7e2ed092011-01-30 11:59:43 -020034 struct thread_map *threads;
35 struct cpu_map *cpus;
Arnaldo Carvalho de Melo81cce8d2011-10-05 19:11:32 -030036 struct perf_evsel *selected;
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020037};
38
Arnaldo Carvalho de Meloee29be62011-11-28 17:57:40 -020039struct perf_evsel_str_handler {
40 const char *name;
41 void *handler;
42};
43
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020044struct perf_evsel;
45
Arnaldo Carvalho de Melo7e2ed092011-01-30 11:59:43 -020046struct perf_evlist *perf_evlist__new(struct cpu_map *cpus,
47 struct thread_map *threads);
48void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
49 struct thread_map *threads);
Arnaldo Carvalho de Meloef1d1af2011-01-18 21:41:45 -020050void perf_evlist__exit(struct perf_evlist *evlist);
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020051void perf_evlist__delete(struct perf_evlist *evlist);
52
53void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
54int perf_evlist__add_default(struct perf_evlist *evlist);
Arnaldo Carvalho de Melo50d08e42011-11-04 09:10:59 -020055int perf_evlist__add_attrs(struct perf_evlist *evlist,
56 struct perf_event_attr *attrs, size_t nr_attrs);
Arnaldo Carvalho de Meloa8c9ae12011-11-05 08:41:51 -020057int perf_evlist__add_tracepoints(struct perf_evlist *evlist,
58 const char *tracepoints[], size_t nr_tracepoints);
Arnaldo Carvalho de Meloee29be62011-11-28 17:57:40 -020059int 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 Melo50d08e42011-11-04 09:10:59 -020062
63#define perf_evlist__add_attrs_array(evlist, array) \
64 perf_evlist__add_attrs(evlist, array, ARRAY_SIZE(array))
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020065
Arnaldo Carvalho de Meloa8c9ae12011-11-05 08:41:51 -020066#define perf_evlist__add_tracepoints_array(evlist, array) \
67 perf_evlist__add_tracepoints(evlist, array, ARRAY_SIZE(array))
68
Arnaldo Carvalho de Meloee29be62011-11-28 17:57:40 -020069#define perf_evlist__set_tracepoints_handlers_array(evlist, array) \
70 perf_evlist__set_tracepoints_handlers(evlist, array, ARRAY_SIZE(array))
71
Arnaldo Carvalho de Meloa91e5432011-03-10 11:15:54 -030072void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
73 int cpu, int thread, u64 id);
Arnaldo Carvalho de Melo3d3b5e92011-03-04 22:29:39 -030074
Arnaldo Carvalho de Melo70082dd2011-01-12 17:03:24 -020075void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
Arnaldo Carvalho de Melo5c581042011-01-11 22:30:02 -020076
Arnaldo Carvalho de Melo70db7532011-01-12 22:39:13 -020077struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
78
Arnaldo Carvalho de Meloaece9482011-05-15 09:39:00 -030079union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
Arnaldo Carvalho de Melo04391de2011-01-15 10:40:59 -020080
Arnaldo Carvalho de Melo727ab042011-10-25 10:42:19 -020081int perf_evlist__open(struct perf_evlist *evlist, bool group);
82
Arnaldo Carvalho de Melo0f82ebc2011-11-08 14:41:57 -020083void perf_evlist__config_attrs(struct perf_evlist *evlist,
84 struct perf_record_opts *opts);
85
Arnaldo Carvalho de Melo35b9d882011-11-09 08:47:15 -020086int perf_evlist__prepare_workload(struct perf_evlist *evlist,
87 struct perf_record_opts *opts,
88 const char *argv[]);
89int perf_evlist__start_workload(struct perf_evlist *evlist);
90
Arnaldo Carvalho de Melo50a682c2011-11-09 09:10:47 -020091int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
92 bool overwrite);
Arnaldo Carvalho de Melo7e2ed092011-01-30 11:59:43 -020093void perf_evlist__munmap(struct perf_evlist *evlist);
94
Arnaldo Carvalho de Melo4152ab32011-07-25 11:06:19 -030095void perf_evlist__disable(struct perf_evlist *evlist);
David Ahern764e16a2011-08-25 10:17:55 -060096void perf_evlist__enable(struct perf_evlist *evlist);
Arnaldo Carvalho de Melo4152ab32011-07-25 11:06:19 -030097
Arnaldo Carvalho de Melo81cce8d2011-10-05 19:11:32 -030098void perf_evlist__set_selected(struct perf_evlist *evlist,
99 struct perf_evsel *evsel);
100
Arnaldo Carvalho de Melo7e2ed092011-01-30 11:59:43 -0200101static 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 Ahernb52956c2012-02-08 09:32:52 -0700109int 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 Melo7e2ed092011-01-30 11:59:43 -0200111void perf_evlist__delete_maps(struct perf_evlist *evlist);
Frederic Weisbecker0a102472011-02-26 04:51:54 +0100112int perf_evlist__set_filters(struct perf_evlist *evlist);
Arnaldo Carvalho de Melof8a95302011-01-30 10:46:46 -0200113
Arnaldo Carvalho de Meloc2a70652011-06-02 11:04:54 -0300114u64 perf_evlist__sample_type(const struct perf_evlist *evlist);
115bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist);
Arnaldo Carvalho de Melo81e36bf2011-11-11 22:28:50 -0200116u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist);
Frederic Weisbecker74429962011-05-21 17:49:00 +0200117
Arnaldo Carvalho de Meloc2a70652011-06-02 11:04:54 -0300118bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
119bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist);
Jiri Olsa0529bc12012-01-27 15:34:20 +0100120
121void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
122 struct list_head *list,
123 int nr_entries);
124
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -0200125#endif /* __PERF_EVLIST_H */