Linux Audio

Check our new training course

Embedded Linux training

Mar 31-Apr 8, 2025
Register
Loading...
v4.6
 
  1#ifndef __PERF_EVLIST_H
  2#define __PERF_EVLIST_H 1
  3
  4#include <linux/atomic.h>
 
 
  5#include <linux/list.h>
  6#include <api/fd/array.h>
  7#include <stdio.h>
  8#include "../perf.h"
  9#include "event.h"
 10#include "evsel.h"
 11#include "util.h"
 12#include "auxtrace.h"
 13#include <unistd.h>
 14
 15struct pollfd;
 16struct thread_map;
 17struct cpu_map;
 18struct record_opts;
 19
 20#define PERF_EVLIST__HLIST_BITS 8
 21#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
 22
 23/**
 24 * struct perf_mmap - perf's ring buffer mmap details
 
 
 
 
 
 25 *
 26 * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
 
 
 
 
 
 
 
 
 27 */
 28struct perf_mmap {
 29	void		 *base;
 30	int		 mask;
 31	atomic_t	 refcnt;
 32	u64		 prev;
 33	struct auxtrace_mmap auxtrace_mmap;
 34	char		 event_copy[PERF_SAMPLE_MAX_SIZE] __attribute__((aligned(8)));
 35};
 36
 37struct perf_evlist {
 38	struct list_head entries;
 39	struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
 40	int		 nr_entries;
 41	int		 nr_groups;
 42	int		 nr_mmaps;
 43	bool		 overwrite;
 44	bool		 enabled;
 45	bool		 has_user_cpus;
 46	size_t		 mmap_len;
 47	int		 id_pos;
 48	int		 is_pos;
 49	u64		 combined_sample_type;
 
 50	struct {
 51		int	cork_fd;
 52		pid_t	pid;
 53	} workload;
 54	struct fdarray	 pollfd;
 55	struct perf_mmap *mmap;
 56	struct thread_map *threads;
 57	struct cpu_map	  *cpus;
 58	struct perf_evsel *selected;
 59	struct events_stats stats;
 60	struct perf_env	*env;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 61};
 62
 63struct perf_evsel_str_handler {
 64	const char *name;
 65	void	   *handler;
 66};
 67
 68struct perf_evlist *perf_evlist__new(void);
 69struct perf_evlist *perf_evlist__new_default(void);
 70struct perf_evlist *perf_evlist__new_dummy(void);
 71void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
 72		       struct thread_map *threads);
 73void perf_evlist__exit(struct perf_evlist *evlist);
 74void perf_evlist__delete(struct perf_evlist *evlist);
 75
 76void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
 77void perf_evlist__remove(struct perf_evlist *evlist, struct perf_evsel *evsel);
 78int perf_evlist__add_default(struct perf_evlist *evlist);
 79int __perf_evlist__add_default_attrs(struct perf_evlist *evlist,
 
 
 
 
 
 
 
 80				     struct perf_event_attr *attrs, size_t nr_attrs);
 81
 82#define perf_evlist__add_default_attrs(evlist, array) \
 83	__perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 84
 85int perf_evlist__add_dummy(struct perf_evlist *evlist);
 
 
 
 86
 87int perf_evlist__add_newtp(struct perf_evlist *evlist,
 88			   const char *sys, const char *name, void *handler);
 89
 90int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter);
 91int perf_evlist__set_filter_pid(struct perf_evlist *evlist, pid_t pid);
 92int perf_evlist__set_filter_pids(struct perf_evlist *evlist, size_t npids, pid_t *pids);
 93
 94struct perf_evsel *
 95perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id);
 
 96
 97struct perf_evsel *
 98perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,
 
 
 
 
 
 
 
 
 99				     const char *name);
100
101void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
102			 int cpu, int thread, u64 id);
103int perf_evlist__id_add_fd(struct perf_evlist *evlist,
104			   struct perf_evsel *evsel,
105			   int cpu, int thread, int fd);
106
107int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
108int perf_evlist__alloc_pollfd(struct perf_evlist *evlist);
109int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask);
110
111int perf_evlist__poll(struct perf_evlist *evlist, int timeout);
112
113struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
114struct perf_evsel *perf_evlist__id2evsel_strict(struct perf_evlist *evlist,
115						u64 id);
116
117struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
118
119union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx);
120
121void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx);
122
123int perf_evlist__open(struct perf_evlist *evlist);
124void perf_evlist__close(struct perf_evlist *evlist);
125
126void perf_evlist__set_id_pos(struct perf_evlist *evlist);
127bool perf_can_sample_identifier(void);
128bool perf_can_record_switch_events(void);
129bool perf_can_record_cpu_wide(void);
130void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts);
131int record_opts__config(struct record_opts *opts);
132
133int perf_evlist__prepare_workload(struct perf_evlist *evlist,
134				  struct target *target,
135				  const char *argv[], bool pipe_output,
136				  void (*exec_error)(int signo, siginfo_t *info,
137						     void *ucontext));
138int perf_evlist__start_workload(struct perf_evlist *evlist);
139
140struct option;
141
142int __perf_evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str);
143int perf_evlist__parse_mmap_pages(const struct option *opt,
144				  const char *str,
145				  int unset);
146
147int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
148			 bool overwrite, unsigned int auxtrace_pages,
149			 bool auxtrace_overwrite);
150int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
151		      bool overwrite);
152void perf_evlist__munmap(struct perf_evlist *evlist);
153
154void perf_evlist__disable(struct perf_evlist *evlist);
155void perf_evlist__enable(struct perf_evlist *evlist);
156void perf_evlist__toggle_enable(struct perf_evlist *evlist);
157
158int perf_evlist__enable_event_idx(struct perf_evlist *evlist,
159				  struct perf_evsel *evsel, int idx);
160
161void perf_evlist__set_selected(struct perf_evlist *evlist,
162			       struct perf_evsel *evsel);
163
164void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus,
165			   struct thread_map *threads);
166int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target);
167int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel);
 
 
168
169void __perf_evlist__set_leader(struct list_head *list);
170void perf_evlist__set_leader(struct perf_evlist *evlist);
171
172u64 perf_evlist__read_format(struct perf_evlist *evlist);
173u64 __perf_evlist__combined_sample_type(struct perf_evlist *evlist);
174u64 perf_evlist__combined_sample_type(struct perf_evlist *evlist);
175u64 perf_evlist__combined_branch_type(struct perf_evlist *evlist);
176bool perf_evlist__sample_id_all(struct perf_evlist *evlist);
177u16 perf_evlist__id_hdr_size(struct perf_evlist *evlist);
178
179int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event,
180			      struct perf_sample *sample);
181
182bool perf_evlist__valid_sample_type(struct perf_evlist *evlist);
183bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist);
184bool perf_evlist__valid_read_format(struct perf_evlist *evlist);
 
 
 
 
185
186void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
187				   struct list_head *list);
188
189static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist)
190{
191	return list_entry(evlist->entries.next, struct perf_evsel, node);
192}
193
194static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist)
195{
196	return list_entry(evlist->entries.prev, struct perf_evsel, node);
197}
198
199size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
200
201int perf_evlist__strerror_open(struct perf_evlist *evlist, int err, char *buf, size_t size);
202int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, size_t size);
203
204static inline u64 perf_mmap__read_head(struct perf_mmap *mm)
205{
206	struct perf_event_mmap_page *pc = mm->base;
207	u64 head = ACCESS_ONCE(pc->data_head);
208	rmb();
209	return head;
210}
211
212static inline void perf_mmap__write_tail(struct perf_mmap *md, u64 tail)
213{
214	struct perf_event_mmap_page *pc = md->base;
215
216	/*
217	 * ensure all reads are done before we write the tail out.
218	 */
219	mb();
220	pc->data_tail = tail;
221}
222
223bool perf_evlist__can_select_event(struct perf_evlist *evlist, const char *str);
224void perf_evlist__to_front(struct perf_evlist *evlist,
225			   struct perf_evsel *move_evsel);
 
 
 
226
227/**
228 * __evlist__for_each - iterate thru all the evsels
229 * @list: list_head instance to iterate
230 * @evsel: struct evsel iterator
231 */
232#define __evlist__for_each(list, evsel) \
233        list_for_each_entry(evsel, list, node)
234
235/**
236 * evlist__for_each - iterate thru all the evsels
237 * @evlist: evlist instance to iterate
238 * @evsel: struct evsel iterator
239 */
240#define evlist__for_each(evlist, evsel) \
241	__evlist__for_each(&(evlist)->entries, evsel)
242
243/**
244 * __evlist__for_each_continue - continue iteration thru all the evsels
245 * @list: list_head instance to iterate
246 * @evsel: struct evsel iterator
247 */
248#define __evlist__for_each_continue(list, evsel) \
249        list_for_each_entry_continue(evsel, list, node)
250
251/**
252 * evlist__for_each_continue - continue iteration thru all the evsels
253 * @evlist: evlist instance to iterate
254 * @evsel: struct evsel iterator
255 */
256#define evlist__for_each_continue(evlist, evsel) \
257	__evlist__for_each_continue(&(evlist)->entries, evsel)
258
259/**
260 * __evlist__for_each_reverse - iterate thru all the evsels in reverse order
261 * @list: list_head instance to iterate
262 * @evsel: struct evsel iterator
263 */
264#define __evlist__for_each_reverse(list, evsel) \
265        list_for_each_entry_reverse(evsel, list, node)
266
267/**
268 * evlist__for_each_reverse - iterate thru all the evsels in reverse order
269 * @evlist: evlist instance to iterate
270 * @evsel: struct evsel iterator
271 */
272#define evlist__for_each_reverse(evlist, evsel) \
273	__evlist__for_each_reverse(&(evlist)->entries, evsel)
274
275/**
276 * __evlist__for_each_safe - safely iterate thru all the evsels
277 * @list: list_head instance to iterate
278 * @tmp: struct evsel temp iterator
279 * @evsel: struct evsel iterator
280 */
281#define __evlist__for_each_safe(list, tmp, evsel) \
282        list_for_each_entry_safe(evsel, tmp, list, node)
283
284/**
285 * evlist__for_each_safe - safely iterate thru all the evsels
286 * @evlist: evlist instance to iterate
287 * @evsel: struct evsel iterator
288 * @tmp: struct evsel temp iterator
289 */
290#define evlist__for_each_safe(evlist, tmp, evsel) \
291	__evlist__for_each_safe(&(evlist)->entries, tmp, evsel)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
293void perf_evlist__set_tracking_event(struct perf_evlist *evlist,
294				     struct perf_evsel *tracking_evsel);
 
 
295
296void perf_event_attr__set_max_precise_ip(struct perf_event_attr *attr);
 
297
298struct perf_evsel *
299perf_evlist__find_evsel_by_str(struct perf_evlist *evlist, const char *str);
300#endif /* __PERF_EVLIST_H */
v5.9
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef __PERF_EVLIST_H
  3#define __PERF_EVLIST_H 1
  4
  5#include <linux/compiler.h>
  6#include <linux/kernel.h>
  7#include <linux/refcount.h>
  8#include <linux/list.h>
  9#include <api/fd/array.h>
 10#include <internal/evlist.h>
 11#include <internal/evsel.h>
 12#include "events_stats.h"
 13#include "evsel.h"
 14#include <pthread.h>
 15#include <signal.h>
 16#include <unistd.h>
 17
 18struct pollfd;
 19struct thread_map;
 20struct perf_cpu_map;
 21struct record_opts;
 22
 23/*
 24 * State machine of bkw_mmap_state:
 25 *
 26 *                     .________________(forbid)_____________.
 27 *                     |                                     V
 28 * NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY
 29 *                     ^  ^              |   ^               |
 30 *                     |  |__(forbid)____/   |___(forbid)___/|
 31 *                     |                                     |
 32 *                      \_________________(3)_______________/
 33 *
 34 * NOTREADY     : Backward ring buffers are not ready
 35 * RUNNING      : Backward ring buffers are recording
 36 * DATA_PENDING : We are required to collect data from backward ring buffers
 37 * EMPTY        : We have collected data from backward ring buffers.
 38 *
 39 * (0): Setup backward ring buffer
 40 * (1): Pause ring buffers for reading
 41 * (2): Read from ring buffers
 42 * (3): Resume ring buffers for recording
 43 */
 44enum bkw_mmap_state {
 45	BKW_MMAP_NOTREADY,
 46	BKW_MMAP_RUNNING,
 47	BKW_MMAP_DATA_PENDING,
 48	BKW_MMAP_EMPTY,
 
 
 49};
 50
 51struct evlist {
 52	struct perf_evlist core;
 
 
 53	int		 nr_groups;
 
 
 54	bool		 enabled;
 
 
 55	int		 id_pos;
 56	int		 is_pos;
 57	u64		 combined_sample_type;
 58	enum bkw_mmap_state bkw_mmap_state;
 59	struct {
 60		int	cork_fd;
 61		pid_t	pid;
 62	} workload;
 63	struct mmap *mmap;
 64	struct mmap *overwrite_mmap;
 65	struct evsel *selected;
 
 
 66	struct events_stats stats;
 67	struct perf_env	*env;
 68	void (*trace_event_sample_raw)(struct evlist *evlist,
 69				       union perf_event *event,
 70				       struct perf_sample *sample);
 71	u64		first_sample_time;
 72	u64		last_sample_time;
 73	struct {
 74		pthread_t		th;
 75		volatile int		done;
 76	} thread;
 77	struct {
 78		int	fd;	/* control file descriptor */
 79		int	ack;	/* ack file descriptor for control commands */
 80		int	pos;	/* index at evlist core object to check signals */
 81	} ctl_fd;
 82};
 83
 84struct evsel_str_handler {
 85	const char *name;
 86	void	   *handler;
 87};
 88
 89struct evlist *evlist__new(void);
 90struct evlist *perf_evlist__new_default(void);
 91struct evlist *perf_evlist__new_dummy(void);
 92void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
 93		  struct perf_thread_map *threads);
 94void evlist__exit(struct evlist *evlist);
 95void evlist__delete(struct evlist *evlist);
 96
 97void evlist__add(struct evlist *evlist, struct evsel *entry);
 98void evlist__remove(struct evlist *evlist, struct evsel *evsel);
 99
100int __evlist__add_default(struct evlist *evlist, bool precise);
101
102static inline int evlist__add_default(struct evlist *evlist)
103{
104	return __evlist__add_default(evlist, true);
105}
106
107int __evlist__add_default_attrs(struct evlist *evlist,
108				     struct perf_event_attr *attrs, size_t nr_attrs);
109
110#define evlist__add_default_attrs(evlist, array) \
111	__evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
112
113int evlist__add_dummy(struct evlist *evlist);
114
115int perf_evlist__add_sb_event(struct evlist *evlist,
116			      struct perf_event_attr *attr,
117			      evsel__sb_cb_t cb,
118			      void *data);
119void evlist__set_cb(struct evlist *evlist, evsel__sb_cb_t cb, void *data);
120int perf_evlist__start_sb_thread(struct evlist *evlist,
121				 struct target *target);
122void perf_evlist__stop_sb_thread(struct evlist *evlist);
123
124int evlist__add_newtp(struct evlist *evlist, const char *sys, const char *name, void *handler);
125
126int __evlist__set_tracepoints_handlers(struct evlist *evlist,
127				       const struct evsel_str_handler *assocs,
128				       size_t nr_assocs);
129
130#define evlist__set_tracepoints_handlers(evlist, array) \
131	__evlist__set_tracepoints_handlers(evlist, array, ARRAY_SIZE(array))
132
133void __perf_evlist__set_sample_bit(struct evlist *evlist,
134				   enum perf_event_sample_format bit);
135void __perf_evlist__reset_sample_bit(struct evlist *evlist,
136				     enum perf_event_sample_format bit);
137
138#define perf_evlist__set_sample_bit(evlist, bit) \
139	__perf_evlist__set_sample_bit(evlist, PERF_SAMPLE_##bit)
140
141#define perf_evlist__reset_sample_bit(evlist, bit) \
142	__perf_evlist__reset_sample_bit(evlist, PERF_SAMPLE_##bit)
 
143
144int perf_evlist__set_tp_filter(struct evlist *evlist, const char *filter);
145int perf_evlist__set_tp_filter_pid(struct evlist *evlist, pid_t pid);
146int perf_evlist__set_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
147
148int perf_evlist__append_tp_filter(struct evlist *evlist, const char *filter);
149
150int perf_evlist__append_tp_filter_pid(struct evlist *evlist, pid_t pid);
151int perf_evlist__append_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
152
153struct evsel *
154perf_evlist__find_tracepoint_by_id(struct evlist *evlist, int id);
155
156struct evsel *
157perf_evlist__find_tracepoint_by_name(struct evlist *evlist,
158				     const char *name);
159
160int evlist__add_pollfd(struct evlist *evlist, int fd);
161int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask);
 
 
 
 
 
 
 
162
163int evlist__poll(struct evlist *evlist, int timeout);
164
165struct evsel *perf_evlist__id2evsel(struct evlist *evlist, u64 id);
166struct evsel *perf_evlist__id2evsel_strict(struct evlist *evlist,
167						u64 id);
168
169struct perf_sample_id *perf_evlist__id2sid(struct evlist *evlist, u64 id);
170
171void perf_evlist__toggle_bkw_mmap(struct evlist *evlist, enum bkw_mmap_state state);
172
173void evlist__mmap_consume(struct evlist *evlist, int idx);
174
175int evlist__open(struct evlist *evlist);
176void evlist__close(struct evlist *evlist);
177
178struct callchain_param;
179
180void perf_evlist__set_id_pos(struct evlist *evlist);
181void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,
182			 struct callchain_param *callchain);
183int record_opts__config(struct record_opts *opts);
184
185int perf_evlist__prepare_workload(struct evlist *evlist,
186				  struct target *target,
187				  const char *argv[], bool pipe_output,
188				  void (*exec_error)(int signo, siginfo_t *info,
189						     void *ucontext));
190int perf_evlist__start_workload(struct evlist *evlist);
191
192struct option;
193
194int __perf_evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str);
195int perf_evlist__parse_mmap_pages(const struct option *opt,
196				  const char *str,
197				  int unset);
198
199unsigned long perf_event_mlock_kb_in_pages(void);
200
201int evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
202			 unsigned int auxtrace_pages,
203			 bool auxtrace_overwrite, int nr_cblocks,
204			 int affinity, int flush, int comp_level);
205int evlist__mmap(struct evlist *evlist, unsigned int pages);
206void evlist__munmap(struct evlist *evlist);
207
208size_t evlist__mmap_size(unsigned long pages);
209
210void evlist__disable(struct evlist *evlist);
211void evlist__enable(struct evlist *evlist);
212void perf_evlist__toggle_enable(struct evlist *evlist);
213
214int perf_evlist__enable_event_idx(struct evlist *evlist,
215				  struct evsel *evsel, int idx);
216
217void perf_evlist__set_selected(struct evlist *evlist,
218			       struct evsel *evsel);
219
220int perf_evlist__create_maps(struct evlist *evlist, struct target *target);
221int perf_evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel);
222
223void __perf_evlist__set_leader(struct list_head *list);
224void perf_evlist__set_leader(struct evlist *evlist);
225
226u64 __evlist__combined_sample_type(struct evlist *evlist);
227u64 evlist__combined_sample_type(struct evlist *evlist);
228u64 evlist__combined_branch_type(struct evlist *evlist);
229bool evlist__sample_id_all(struct evlist *evlist);
230u16 perf_evlist__id_hdr_size(struct evlist *evlist);
 
231
232int perf_evlist__parse_sample(struct evlist *evlist, union perf_event *event,
233			      struct perf_sample *sample);
234
235int perf_evlist__parse_sample_timestamp(struct evlist *evlist,
236					union perf_event *event,
237					u64 *timestamp);
238
239bool evlist__valid_sample_type(struct evlist *evlist);
240bool evlist__valid_sample_id_all(struct evlist *evlist);
241bool perf_evlist__valid_read_format(struct evlist *evlist);
242
243void perf_evlist__splice_list_tail(struct evlist *evlist,
244				   struct list_head *list);
245
246static inline bool perf_evlist__empty(struct evlist *evlist)
247{
248	return list_empty(&evlist->core.entries);
249}
250
251static inline struct evsel *evlist__first(struct evlist *evlist)
252{
253	struct perf_evsel *evsel = perf_evlist__first(&evlist->core);
 
254
255	return container_of(evsel, struct evsel, core);
 
 
 
 
 
 
 
 
 
 
256}
257
258static inline struct evsel *evlist__last(struct evlist *evlist)
259{
260	struct perf_evsel *evsel = perf_evlist__last(&evlist->core);
261
262	return container_of(evsel, struct evsel, core);
 
 
 
 
263}
264
265int evlist__strerror_open(struct evlist *evlist, int err, char *buf, size_t size);
266int evlist__strerror_mmap(struct evlist *evlist, int err, char *buf, size_t size);
267
268bool perf_evlist__can_select_event(struct evlist *evlist, const char *str);
269void perf_evlist__to_front(struct evlist *evlist,
270			   struct evsel *move_evsel);
271
272/**
273 * __evlist__for_each_entry - iterate thru all the evsels
274 * @list: list_head instance to iterate
275 * @evsel: struct evsel iterator
276 */
277#define __evlist__for_each_entry(list, evsel) \
278        list_for_each_entry(evsel, list, core.node)
279
280/**
281 * evlist__for_each_entry - iterate thru all the evsels
282 * @evlist: evlist instance to iterate
283 * @evsel: struct evsel iterator
284 */
285#define evlist__for_each_entry(evlist, evsel) \
286	__evlist__for_each_entry(&(evlist)->core.entries, evsel)
287
288/**
289 * __evlist__for_each_entry_continue - continue iteration thru all the evsels
290 * @list: list_head instance to iterate
291 * @evsel: struct evsel iterator
292 */
293#define __evlist__for_each_entry_continue(list, evsel) \
294        list_for_each_entry_continue(evsel, list, core.node)
295
296/**
297 * evlist__for_each_entry_continue - continue iteration thru all the evsels
298 * @evlist: evlist instance to iterate
299 * @evsel: struct evsel iterator
300 */
301#define evlist__for_each_entry_continue(evlist, evsel) \
302	__evlist__for_each_entry_continue(&(evlist)->core.entries, evsel)
303
304/**
305 * __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
306 * @list: list_head instance to iterate
307 * @evsel: struct evsel iterator
308 */
309#define __evlist__for_each_entry_reverse(list, evsel) \
310        list_for_each_entry_reverse(evsel, list, core.node)
311
312/**
313 * evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
314 * @evlist: evlist instance to iterate
315 * @evsel: struct evsel iterator
316 */
317#define evlist__for_each_entry_reverse(evlist, evsel) \
318	__evlist__for_each_entry_reverse(&(evlist)->core.entries, evsel)
319
320/**
321 * __evlist__for_each_entry_safe - safely iterate thru all the evsels
322 * @list: list_head instance to iterate
323 * @tmp: struct evsel temp iterator
324 * @evsel: struct evsel iterator
325 */
326#define __evlist__for_each_entry_safe(list, tmp, evsel) \
327        list_for_each_entry_safe(evsel, tmp, list, core.node)
328
329/**
330 * evlist__for_each_entry_safe - safely iterate thru all the evsels
331 * @evlist: evlist instance to iterate
332 * @evsel: struct evsel iterator
333 * @tmp: struct evsel temp iterator
334 */
335#define evlist__for_each_entry_safe(evlist, tmp, evsel) \
336	__evlist__for_each_entry_safe(&(evlist)->core.entries, tmp, evsel)
337
338#define evlist__for_each_cpu(evlist, index, cpu)	\
339	evlist__cpu_iter_start(evlist);			\
340	perf_cpu_map__for_each_cpu (cpu, index, (evlist)->core.all_cpus)
341
342struct evsel *perf_evlist__get_tracking_event(struct evlist *evlist);
343void perf_evlist__set_tracking_event(struct evlist *evlist,
344				     struct evsel *tracking_evsel);
345
346void evlist__cpu_iter_start(struct evlist *evlist);
347bool evsel__cpu_iter_skip(struct evsel *ev, int cpu);
348bool evsel__cpu_iter_skip_no_inc(struct evsel *ev, int cpu);
349
350struct evsel *
351perf_evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
352
353struct evsel *perf_evlist__event2evsel(struct evlist *evlist,
354					    union perf_event *event);
355
356bool perf_evlist__exclude_kernel(struct evlist *evlist);
357
358void perf_evlist__force_leader(struct evlist *evlist);
359
360struct evsel *perf_evlist__reset_weak_group(struct evlist *evlist,
361						 struct evsel *evsel,
362						bool close);
363#define EVLIST_CTL_CMD_ENABLE_TAG  "enable"
364#define EVLIST_CTL_CMD_DISABLE_TAG "disable"
365#define EVLIST_CTL_CMD_ACK_TAG     "ack\n"
366
367#define EVLIST_CTL_CMD_MAX_LEN 64
368
369enum evlist_ctl_cmd {
370	EVLIST_CTL_CMD_UNSUPPORTED = 0,
371	EVLIST_CTL_CMD_ENABLE,
372	EVLIST_CTL_CMD_DISABLE,
373	EVLIST_CTL_CMD_ACK
374};
375
376int evlist__initialize_ctlfd(struct evlist *evlist, int ctl_fd, int ctl_fd_ack);
377int evlist__finalize_ctlfd(struct evlist *evlist);
378bool evlist__ctlfd_initialized(struct evlist *evlist);
379int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd);
380
381#define EVLIST_ENABLED_MSG "Events enabled\n"
382#define EVLIST_DISABLED_MSG "Events disabled\n"
383
 
 
384#endif /* __PERF_EVLIST_H */