evlist.h 3.6 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
};

struct perf_evsel;

41 42 43 44
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);
45
void perf_evlist__exit(struct perf_evlist *evlist);
46 47 48 49
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);
50 51
int perf_evlist__add_attrs(struct perf_evlist *evlist,
			   struct perf_event_attr *attrs, size_t nr_attrs);
52 53
int perf_evlist__add_tracepoints(struct perf_evlist *evlist,
				 const char *tracepoints[], size_t nr_tracepoints);
54 55 56

#define perf_evlist__add_attrs_array(evlist, array) \
	perf_evlist__add_attrs(evlist, array, ARRAY_SIZE(array))
57

58 59 60
#define perf_evlist__add_tracepoints_array(evlist, array) \
	perf_evlist__add_tracepoints(evlist, array, ARRAY_SIZE(array))

61 62
void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
			 int cpu, int thread, u64 id);
63

64
int perf_evlist__alloc_pollfd(struct perf_evlist *evlist);
65
void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
66

67 68
struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);

69
union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
70

71 72
int perf_evlist__open(struct perf_evlist *evlist, bool group);

73 74 75
void perf_evlist__config_attrs(struct perf_evlist *evlist,
			       struct perf_record_opts *opts);

76 77 78 79 80
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);

81
int perf_evlist__alloc_mmap(struct perf_evlist *evlist);
82 83
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
		      bool overwrite);
84 85
void perf_evlist__munmap(struct perf_evlist *evlist);

86
void perf_evlist__disable(struct perf_evlist *evlist);
87
void perf_evlist__enable(struct perf_evlist *evlist);
88

89 90 91
void perf_evlist__set_selected(struct perf_evlist *evlist,
			       struct perf_evsel *evsel);

92 93 94 95 96 97 98 99 100 101 102
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;
}

int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid,
			     pid_t target_tid, const char *cpu_list);
void perf_evlist__delete_maps(struct perf_evlist *evlist);
103
int perf_evlist__set_filters(struct perf_evlist *evlist);
104

105 106
u64 perf_evlist__sample_type(const struct perf_evlist *evlist);
bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist);
107
u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist);
108

109 110
bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist);
111
#endif /* __PERF_EVLIST_H */