evlist.h 4.4 KB
Newer Older
1 2 3 4
#ifndef __PERF_EVLIST_H
#define __PERF_EVLIST_H 1

#include <linux/list.h>
5
#include <stdio.h>
6
#include "../perf.h"
7
#include "event.h"
8
#include "util.h"
9
#include <unistd.h>
10

11
struct pollfd;
12 13
struct thread_map;
struct cpu_map;
14
struct perf_record_opts;
15

16 17 18
#define PERF_EVLIST__HLIST_BITS 8
#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)

19 20
struct perf_evlist {
	struct list_head entries;
21
	struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
22
	int		 nr_entries;
23
	int		 nr_fds;
24
	int		 nr_mmaps;
25
	int		 mmap_len;
26 27 28 29
	struct {
		int	cork_fd;
		pid_t	pid;
	} workload;
30
	bool		 overwrite;
31
	union perf_event event_copy;
32
	struct perf_mmap *mmap;
33
	struct pollfd	 *pollfd;
34 35
	struct thread_map *threads;
	struct cpu_map	  *cpus;
36
	struct perf_evsel *selected;
37 38
};

39 40 41 42 43
struct perf_evsel_str_handler {
	const char *name;
	void	   *handler;
};

44 45
struct perf_evsel;

46 47 48 49
struct perf_evlist *perf_evlist__new(struct cpu_map *cpus,
				     struct thread_map *threads);
void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
		       struct thread_map *threads);
50
void perf_evlist__exit(struct perf_evlist *evlist);
51 52 53 54
void perf_evlist__delete(struct perf_evlist *evlist);

void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
int perf_evlist__add_default(struct perf_evlist *evlist);
55 56
int perf_evlist__add_attrs(struct perf_evlist *evlist,
			   struct perf_event_attr *attrs, size_t nr_attrs);
57 58
int __perf_evlist__add_default_attrs(struct perf_evlist *evlist,
				     struct perf_event_attr *attrs, size_t nr_attrs);
59 60
int perf_evlist__add_tracepoints(struct perf_evlist *evlist,
				 const char *tracepoints[], size_t nr_tracepoints);
61 62 63
int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist,
					  const struct perf_evsel_str_handler *assocs,
					  size_t nr_assocs);
64 65 66

#define perf_evlist__add_attrs_array(evlist, array) \
	perf_evlist__add_attrs(evlist, array, ARRAY_SIZE(array))
67 68
#define perf_evlist__add_default_attrs(evlist, array) \
	__perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
69

70 71 72
#define perf_evlist__add_tracepoints_array(evlist, array) \
	perf_evlist__add_tracepoints(evlist, array, ARRAY_SIZE(array))

73 74 75
#define perf_evlist__set_tracepoints_handlers_array(evlist, array) \
	perf_evlist__set_tracepoints_handlers(evlist, array, ARRAY_SIZE(array))

76 77 78
struct perf_evsel *
perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id);

79 80
void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
			 int cpu, int thread, u64 id);
81

82
void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
83

84 85
struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);

86
union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
87

88 89
int perf_evlist__open(struct perf_evlist *evlist, bool group);

90 91 92
void perf_evlist__config_attrs(struct perf_evlist *evlist,
			       struct perf_record_opts *opts);

93 94 95 96 97
int perf_evlist__prepare_workload(struct perf_evlist *evlist,
				  struct perf_record_opts *opts,
				  const char *argv[]);
int perf_evlist__start_workload(struct perf_evlist *evlist);

98 99
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
		      bool overwrite);
100 101
void perf_evlist__munmap(struct perf_evlist *evlist);

102
void perf_evlist__disable(struct perf_evlist *evlist);
103
void perf_evlist__enable(struct perf_evlist *evlist);
104

105 106 107
void perf_evlist__set_selected(struct perf_evlist *evlist,
			       struct perf_evsel *evsel);

108 109 110 111 112 113 114 115
static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
					 struct cpu_map *cpus,
					 struct thread_map *threads)
{
	evlist->cpus	= cpus;
	evlist->threads	= threads;
}

116 117
int perf_evlist__create_maps(struct perf_evlist *evlist,
			     struct perf_target *target);
118
void perf_evlist__delete_maps(struct perf_evlist *evlist);
119
int perf_evlist__set_filters(struct perf_evlist *evlist);
120

121 122
u64 perf_evlist__sample_type(const struct perf_evlist *evlist);
bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist);
123
u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist);
124

125
int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event,
126 127
			      struct perf_sample *sample, bool swapped);

128 129
bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist);
130 131 132 133 134

void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
				   struct list_head *list,
				   int nr_entries);

135
#endif /* __PERF_EVLIST_H */