Lines Matching +full:cpu +full:- +full:nr
1 // SPDX-License-Identifier: GPL-2.0
21 INIT_LIST_HEAD(&evsel->node); in perf_evsel__init()
22 evsel->attr = *attr; in perf_evsel__init()
40 #define FD(e, x, y) (*(int *) xyarray__entry(e->fd, x, y))
44 evsel->fd = xyarray__new(ncpus, nthreads, sizeof(int)); in perf_evsel__alloc_fd()
46 if (evsel->fd) { in perf_evsel__alloc_fd()
47 int cpu, thread; in perf_evsel__alloc_fd() local
48 for (cpu = 0; cpu < ncpus; cpu++) { in perf_evsel__alloc_fd()
50 FD(evsel, cpu, thread) = -1; in perf_evsel__alloc_fd()
55 return evsel->fd != NULL ? 0 : -ENOMEM; in perf_evsel__alloc_fd()
60 pid_t pid, int cpu, int group_fd, in sys_perf_event_open() argument
63 return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags); in sys_perf_event_open()
69 int cpu, thread, err = 0; in perf_evsel__open() local
77 return -ENOMEM; in perf_evsel__open()
89 return -ENOMEM; in perf_evsel__open()
95 if (evsel->fd == NULL && in perf_evsel__open()
96 perf_evsel__alloc_fd(evsel, cpus->nr, threads->nr) < 0) in perf_evsel__open()
97 return -ENOMEM; in perf_evsel__open()
99 for (cpu = 0; cpu < cpus->nr; cpu++) { in perf_evsel__open()
100 for (thread = 0; thread < threads->nr; thread++) { in perf_evsel__open()
103 fd = sys_perf_event_open(&evsel->attr, in perf_evsel__open()
104 threads->map[thread].pid, in perf_evsel__open()
105 cpus->map[cpu], -1, 0); in perf_evsel__open()
108 return -errno; in perf_evsel__open()
110 FD(evsel, cpu, thread) = fd; in perf_evsel__open()
117 static void perf_evsel__close_fd_cpu(struct perf_evsel *evsel, int cpu) in perf_evsel__close_fd_cpu() argument
121 for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) { in perf_evsel__close_fd_cpu()
122 if (FD(evsel, cpu, thread) >= 0) in perf_evsel__close_fd_cpu()
123 close(FD(evsel, cpu, thread)); in perf_evsel__close_fd_cpu()
124 FD(evsel, cpu, thread) = -1; in perf_evsel__close_fd_cpu()
130 int cpu; in perf_evsel__close_fd() local
132 for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) in perf_evsel__close_fd()
133 perf_evsel__close_fd_cpu(evsel, cpu); in perf_evsel__close_fd()
138 xyarray__delete(evsel->fd); in perf_evsel__free_fd()
139 evsel->fd = NULL; in perf_evsel__free_fd()
144 if (evsel->fd == NULL) in perf_evsel__close()
151 void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu) in perf_evsel__close_cpu() argument
153 if (evsel->fd == NULL) in perf_evsel__close_cpu()
156 perf_evsel__close_fd_cpu(evsel, cpu); in perf_evsel__close_cpu()
161 u64 read_format = evsel->attr.read_format; in perf_evsel__read_size()
164 int nr = 1; in perf_evsel__read_size() local
176 nr = evsel->nr_members; in perf_evsel__read_size()
180 size += entry * nr; in perf_evsel__read_size()
184 int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, in perf_evsel__read() argument
191 if (FD(evsel, cpu, thread) < 0) in perf_evsel__read()
192 return -EINVAL; in perf_evsel__read()
194 if (readn(FD(evsel, cpu, thread), count->values, size) <= 0) in perf_evsel__read()
195 return -errno; in perf_evsel__read()
202 int cpu) in perf_evsel__run_ioctl() argument
206 for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) { in perf_evsel__run_ioctl()
207 int fd = FD(evsel, cpu, thread), in perf_evsel__run_ioctl()
217 int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu) in perf_evsel__enable_cpu() argument
219 return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, NULL, cpu); in perf_evsel__enable_cpu()
227 for (i = 0; i < xyarray__max_x(evsel->fd) && !err; i++) in perf_evsel__enable()
232 int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu) in perf_evsel__disable_cpu() argument
234 return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, NULL, cpu); in perf_evsel__disable_cpu()
242 for (i = 0; i < xyarray__max_x(evsel->fd) && !err; i++) in perf_evsel__disable()
251 for (i = 0; i < evsel->cpus->nr && !err; i++) in perf_evsel__apply_filter()
260 return evsel->cpus; in perf_evsel__cpus()
265 return evsel->threads; in perf_evsel__threads()
270 return &evsel->attr; in perf_evsel__attr()
278 if (evsel->system_wide) in perf_evsel__alloc_id()
281 evsel->sample_id = xyarray__new(ncpus, nthreads, sizeof(struct perf_sample_id)); in perf_evsel__alloc_id()
282 if (evsel->sample_id == NULL) in perf_evsel__alloc_id()
283 return -ENOMEM; in perf_evsel__alloc_id()
285 evsel->id = zalloc(ncpus * nthreads * sizeof(u64)); in perf_evsel__alloc_id()
286 if (evsel->id == NULL) { in perf_evsel__alloc_id()
287 xyarray__delete(evsel->sample_id); in perf_evsel__alloc_id()
288 evsel->sample_id = NULL; in perf_evsel__alloc_id()
289 return -ENOMEM; in perf_evsel__alloc_id()
297 xyarray__delete(evsel->sample_id); in perf_evsel__free_id()
298 evsel->sample_id = NULL; in perf_evsel__free_id()
299 zfree(&evsel->id); in perf_evsel__free_id()
300 evsel->ids = 0; in perf_evsel__free_id()