Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
evlist.h
Go to the documentation of this file.
1 #ifndef __PERF_EVLIST_H
2 #define __PERF_EVLIST_H 1
3 
4 #include <linux/list.h>
5 #include <stdio.h>
6 #include "../perf.h"
7 #include "event.h"
8 #include "evsel.h"
9 #include "util.h"
10 #include <unistd.h>
11 
12 struct pollfd;
13 struct thread_map;
14 struct cpu_map;
15 struct perf_record_opts;
16 
17 #define PERF_EVLIST__HLIST_BITS 8
18 #define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
19 
20 struct perf_evlist {
24  int nr_fds;
25  int nr_mmaps;
26  int mmap_len;
27  struct {
28  int cork_fd;
30  } workload;
31  bool overwrite;
33  struct perf_mmap *mmap;
34  struct pollfd *pollfd;
36  struct cpu_map *cpus;
38 };
39 
41  const char *name;
42  void *handler;
43 };
44 
46  struct thread_map *threads);
47 void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
48  struct thread_map *threads);
49 void perf_evlist__exit(struct perf_evlist *evlist);
50 void perf_evlist__delete(struct perf_evlist *evlist);
51 
52 void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
53 int perf_evlist__add_default(struct perf_evlist *evlist);
55  struct perf_event_attr *attrs, size_t nr_attrs);
56 
57 #define perf_evlist__add_default_attrs(evlist, array) \
58  __perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
59 
60 int perf_evlist__add_newtp(struct perf_evlist *evlist,
61  const char *sys, const char *name, void *handler);
62 
63 int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter);
64 
65 struct perf_evsel *
66 perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id);
67 
68 void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
69  int cpu, int thread, u64 id);
70 
71 void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
72 
73 struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
74 
75 union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
76 
77 int perf_evlist__open(struct perf_evlist *evlist);
78 
79 void perf_evlist__config_attrs(struct perf_evlist *evlist,
80  struct perf_record_opts *opts);
81 
83  struct perf_record_opts *opts,
84  const char *argv[]);
85 int perf_evlist__start_workload(struct perf_evlist *evlist);
86 
87 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
88  bool overwrite);
89 void perf_evlist__munmap(struct perf_evlist *evlist);
90 
91 void perf_evlist__disable(struct perf_evlist *evlist);
92 void perf_evlist__enable(struct perf_evlist *evlist);
93 
94 void perf_evlist__set_selected(struct perf_evlist *evlist,
95  struct perf_evsel *evsel);
96 
97 static 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 
105 int perf_evlist__create_maps(struct perf_evlist *evlist,
106  struct perf_target *target);
107 void perf_evlist__delete_maps(struct perf_evlist *evlist);
108 int perf_evlist__apply_filters(struct perf_evlist *evlist);
109 
111 void perf_evlist__set_leader(struct perf_evlist *evlist);
112 
114 bool perf_evlist__sample_id_all(struct perf_evlist *evlist);
116 
117 int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event,
118  struct perf_sample *sample);
119 
120 bool perf_evlist__valid_sample_type(struct perf_evlist *evlist);
121 bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist);
122 
123 void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
124  struct list_head *list,
125  int nr_entries);
126 
127 static 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 
132 static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist)
133 {
134  return list_entry(evlist->entries.prev, struct perf_evsel, node);
135 }
136 
137 size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
138 #endif /* __PERF_EVLIST_H */