evlist.h 4.1 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
void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
			 int cpu, int thread, u64 id);
78

79
void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
80

81 82
struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);

83
union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
84

85 86
int perf_evlist__open(struct perf_evlist *evlist, bool group);

87 88 89
void perf_evlist__config_attrs(struct perf_evlist *evlist,
			       struct perf_record_opts *opts);

90 91 92 93 94
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);

95 96
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
		      bool overwrite);
97 98
void perf_evlist__munmap(struct perf_evlist *evlist);

99
void perf_evlist__disable(struct perf_evlist *evlist);
100
void perf_evlist__enable(struct perf_evlist *evlist);
101

102 103 104
void perf_evlist__set_selected(struct perf_evlist *evlist,
			       struct perf_evsel *evsel);

105 106 107 108 109 110 111 112
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;
}

113 114
int perf_evlist__create_maps(struct perf_evlist *evlist,
			     struct perf_target *target);
115
void perf_evlist__delete_maps(struct perf_evlist *evlist);
116
int perf_evlist__set_filters(struct perf_evlist *evlist);
117

118 119
u64 perf_evlist__sample_type(const struct perf_evlist *evlist);
bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist);
120
u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist);
121

122 123
bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist);
124 125 126 127 128

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

129
#endif /* __PERF_EVLIST_H */