]> git.karo-electronics.de Git - linux-beck.git/blob - tools/perf/util/evlist.h
perf evlist: Introduce perf_evlist__add_attrs
[linux-beck.git] / tools / perf / util / evlist.h
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 "util.h"
9
10 struct pollfd;
11 struct thread_map;
12 struct cpu_map;
13
14 #define PERF_EVLIST__HLIST_BITS 8
15 #define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
16
17 struct perf_evlist {
18         struct list_head entries;
19         struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
20         int              nr_entries;
21         int              nr_fds;
22         int              nr_mmaps;
23         int              mmap_len;
24         bool             overwrite;
25         union perf_event event_copy;
26         struct perf_mmap *mmap;
27         struct pollfd    *pollfd;
28         struct thread_map *threads;
29         struct cpu_map    *cpus;
30         struct perf_evsel *selected;
31 };
32
33 struct perf_evsel;
34
35 struct perf_evlist *perf_evlist__new(struct cpu_map *cpus,
36                                      struct thread_map *threads);
37 void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
38                        struct thread_map *threads);
39 void perf_evlist__exit(struct perf_evlist *evlist);
40 void perf_evlist__delete(struct perf_evlist *evlist);
41
42 void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
43 int perf_evlist__add_default(struct perf_evlist *evlist);
44 int perf_evlist__add_attrs(struct perf_evlist *evlist,
45                            struct perf_event_attr *attrs, size_t nr_attrs);
46
47 #define perf_evlist__add_attrs_array(evlist, array) \
48         perf_evlist__add_attrs(evlist, array, ARRAY_SIZE(array))
49
50 void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
51                          int cpu, int thread, u64 id);
52
53 int perf_evlist__alloc_pollfd(struct perf_evlist *evlist);
54 void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
55
56 struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
57
58 union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
59
60 int perf_evlist__open(struct perf_evlist *evlist, bool group);
61
62 int perf_evlist__alloc_mmap(struct perf_evlist *evlist);
63 int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite);
64 void perf_evlist__munmap(struct perf_evlist *evlist);
65
66 void perf_evlist__disable(struct perf_evlist *evlist);
67 void perf_evlist__enable(struct perf_evlist *evlist);
68
69 void perf_evlist__set_selected(struct perf_evlist *evlist,
70                                struct perf_evsel *evsel);
71
72 static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
73                                          struct cpu_map *cpus,
74                                          struct thread_map *threads)
75 {
76         evlist->cpus    = cpus;
77         evlist->threads = threads;
78 }
79
80 int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid,
81                              pid_t target_tid, const char *cpu_list);
82 void perf_evlist__delete_maps(struct perf_evlist *evlist);
83 int perf_evlist__set_filters(struct perf_evlist *evlist);
84
85 u64 perf_evlist__sample_type(const struct perf_evlist *evlist);
86 bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist);
87
88 bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
89 bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist);
90 #endif /* __PERF_EVLIST_H */