• Home
  • Raw
  • Download

Lines Matching refs:evsel

22 void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr,  in perf_evsel__init()  argument
25 INIT_LIST_HEAD(&evsel->node); in perf_evsel__init()
26 evsel->attr = *attr; in perf_evsel__init()
27 evsel->idx = idx; in perf_evsel__init()
28 evsel->leader = evsel; in perf_evsel__init()
33 struct perf_evsel *evsel = zalloc(sizeof(*evsel)); in perf_evsel__new() local
35 if (evsel != NULL) in perf_evsel__new()
36 perf_evsel__init(evsel, attr, 0); in perf_evsel__new()
38 return evsel; in perf_evsel__new()
41 void perf_evsel__delete(struct perf_evsel *evsel) in perf_evsel__delete() argument
43 free(evsel); in perf_evsel__delete()
49 int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads) in perf_evsel__alloc_fd() argument
51 evsel->fd = xyarray__new(ncpus, nthreads, sizeof(int)); in perf_evsel__alloc_fd()
53 if (evsel->fd) { in perf_evsel__alloc_fd()
57 int *fd = FD(evsel, cpu, thread); in perf_evsel__alloc_fd()
65 return evsel->fd != NULL ? 0 : -ENOMEM; in perf_evsel__alloc_fd()
68 static int perf_evsel__alloc_mmap(struct perf_evsel *evsel, int ncpus, int nthreads) in perf_evsel__alloc_mmap() argument
70 evsel->mmap = xyarray__new(ncpus, nthreads, sizeof(struct perf_mmap)); in perf_evsel__alloc_mmap()
72 return evsel->mmap != NULL ? 0 : -ENOMEM; in perf_evsel__alloc_mmap()
83 static int get_group_fd(struct perf_evsel *evsel, int cpu, int thread, int *group_fd) in get_group_fd() argument
85 struct perf_evsel *leader = evsel->leader; in get_group_fd()
88 if (evsel == leader) { in get_group_fd()
109 int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus, in perf_evsel__open() argument
138 if (evsel->fd == NULL && in perf_evsel__open()
139 perf_evsel__alloc_fd(evsel, cpus->nr, threads->nr) < 0) in perf_evsel__open()
146 evsel_fd = FD(evsel, cpu, thread); in perf_evsel__open()
150 err = get_group_fd(evsel, cpu, thread, &group_fd); in perf_evsel__open()
154 fd = sys_perf_event_open(&evsel->attr, in perf_evsel__open()
168 static void perf_evsel__close_fd_cpu(struct perf_evsel *evsel, int cpu) in perf_evsel__close_fd_cpu() argument
172 for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) { in perf_evsel__close_fd_cpu()
173 int *fd = FD(evsel, cpu, thread); in perf_evsel__close_fd_cpu()
182 void perf_evsel__close_fd(struct perf_evsel *evsel) in perf_evsel__close_fd() argument
186 for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) in perf_evsel__close_fd()
187 perf_evsel__close_fd_cpu(evsel, cpu); in perf_evsel__close_fd()
190 void perf_evsel__free_fd(struct perf_evsel *evsel) in perf_evsel__free_fd() argument
192 xyarray__delete(evsel->fd); in perf_evsel__free_fd()
193 evsel->fd = NULL; in perf_evsel__free_fd()
196 void perf_evsel__close(struct perf_evsel *evsel) in perf_evsel__close() argument
198 if (evsel->fd == NULL) in perf_evsel__close()
201 perf_evsel__close_fd(evsel); in perf_evsel__close()
202 perf_evsel__free_fd(evsel); in perf_evsel__close()
205 void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu) in perf_evsel__close_cpu() argument
207 if (evsel->fd == NULL) in perf_evsel__close_cpu()
210 perf_evsel__close_fd_cpu(evsel, cpu); in perf_evsel__close_cpu()
213 void perf_evsel__munmap(struct perf_evsel *evsel) in perf_evsel__munmap() argument
217 if (evsel->fd == NULL || evsel->mmap == NULL) in perf_evsel__munmap()
220 for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { in perf_evsel__munmap()
221 for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) { in perf_evsel__munmap()
222 int *fd = FD(evsel, cpu, thread); in perf_evsel__munmap()
227 perf_mmap__munmap(MMAP(evsel, cpu, thread)); in perf_evsel__munmap()
231 xyarray__delete(evsel->mmap); in perf_evsel__munmap()
232 evsel->mmap = NULL; in perf_evsel__munmap()
235 int perf_evsel__mmap(struct perf_evsel *evsel, int pages) in perf_evsel__mmap() argument
243 if (evsel->fd == NULL || evsel->mmap) in perf_evsel__mmap()
246 if (perf_evsel__alloc_mmap(evsel, xyarray__max_x(evsel->fd), xyarray__max_y(evsel->fd)) < 0) in perf_evsel__mmap()
249 for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { in perf_evsel__mmap()
250 for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) { in perf_evsel__mmap()
251 int *fd = FD(evsel, cpu, thread); in perf_evsel__mmap()
257 map = MMAP(evsel, cpu, thread); in perf_evsel__mmap()
262 perf_evsel__munmap(evsel); in perf_evsel__mmap()
271 void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu, int thread) in perf_evsel__mmap_base() argument
273 int *fd = FD(evsel, cpu, thread); in perf_evsel__mmap_base()
275 if (fd == NULL || *fd < 0 || MMAP(evsel, cpu, thread) == NULL) in perf_evsel__mmap_base()
278 return MMAP(evsel, cpu, thread)->base; in perf_evsel__mmap_base()
281 int perf_evsel__read_size(struct perf_evsel *evsel) in perf_evsel__read_size() argument
283 u64 read_format = evsel->attr.read_format; in perf_evsel__read_size()
298 nr = evsel->nr_members; in perf_evsel__read_size()
306 int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, in perf_evsel__read() argument
309 size_t size = perf_evsel__read_size(evsel); in perf_evsel__read()
310 int *fd = FD(evsel, cpu, thread); in perf_evsel__read()
317 if (MMAP(evsel, cpu, thread) && in perf_evsel__read()
318 !perf_mmap__read_self(MMAP(evsel, cpu, thread), count)) in perf_evsel__read()
327 static int perf_evsel__run_ioctl(struct perf_evsel *evsel, in perf_evsel__run_ioctl() argument
333 for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) { in perf_evsel__run_ioctl()
335 int *fd = FD(evsel, cpu, thread); in perf_evsel__run_ioctl()
349 int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu) in perf_evsel__enable_cpu() argument
351 return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, NULL, cpu); in perf_evsel__enable_cpu()
354 int perf_evsel__enable(struct perf_evsel *evsel) in perf_evsel__enable() argument
359 for (i = 0; i < xyarray__max_x(evsel->fd) && !err; i++) in perf_evsel__enable()
360 err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, NULL, i); in perf_evsel__enable()
364 int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu) in perf_evsel__disable_cpu() argument
366 return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, NULL, cpu); in perf_evsel__disable_cpu()
369 int perf_evsel__disable(struct perf_evsel *evsel) in perf_evsel__disable() argument
374 for (i = 0; i < xyarray__max_x(evsel->fd) && !err; i++) in perf_evsel__disable()
375 err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, NULL, i); in perf_evsel__disable()
379 int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter) in perf_evsel__apply_filter() argument
383 for (i = 0; i < evsel->cpus->nr && !err; i++) in perf_evsel__apply_filter()
384 err = perf_evsel__run_ioctl(evsel, in perf_evsel__apply_filter()
390 struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel) in perf_evsel__cpus() argument
392 return evsel->cpus; in perf_evsel__cpus()
395 struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel) in perf_evsel__threads() argument
397 return evsel->threads; in perf_evsel__threads()
400 struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel) in perf_evsel__attr() argument
402 return &evsel->attr; in perf_evsel__attr()
405 int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads) in perf_evsel__alloc_id() argument
410 if (evsel->system_wide) in perf_evsel__alloc_id()
413 evsel->sample_id = xyarray__new(ncpus, nthreads, sizeof(struct perf_sample_id)); in perf_evsel__alloc_id()
414 if (evsel->sample_id == NULL) in perf_evsel__alloc_id()
417 evsel->id = zalloc(ncpus * nthreads * sizeof(u64)); in perf_evsel__alloc_id()
418 if (evsel->id == NULL) { in perf_evsel__alloc_id()
419 xyarray__delete(evsel->sample_id); in perf_evsel__alloc_id()
420 evsel->sample_id = NULL; in perf_evsel__alloc_id()
427 void perf_evsel__free_id(struct perf_evsel *evsel) in perf_evsel__free_id() argument
429 xyarray__delete(evsel->sample_id); in perf_evsel__free_id()
430 evsel->sample_id = NULL; in perf_evsel__free_id()
431 zfree(&evsel->id); in perf_evsel__free_id()
432 evsel->ids = 0; in perf_evsel__free_id()