.. | .. |
---|
9 | 9 | #include <fcntl.h> |
---|
10 | 10 | #include <api/fs/fs.h> |
---|
11 | 11 | #include <linux/err.h> |
---|
| 12 | +#include <linux/string.h> |
---|
12 | 13 | #include <api/fs/tracing_path.h> |
---|
13 | 14 | #include "evsel.h" |
---|
14 | 15 | #include "tests.h" |
---|
15 | 16 | #include "thread_map.h" |
---|
16 | | -#include "cpumap.h" |
---|
| 17 | +#include <perf/cpumap.h> |
---|
| 18 | +#include <internal/cpumap.h> |
---|
17 | 19 | #include "debug.h" |
---|
18 | 20 | #include "stat.h" |
---|
| 21 | +#include "util/counts.h" |
---|
19 | 22 | |
---|
20 | 23 | int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int subtest __maybe_unused) |
---|
21 | 24 | { |
---|
22 | 25 | int err = -1, fd, cpu; |
---|
23 | | - struct cpu_map *cpus; |
---|
24 | | - struct perf_evsel *evsel; |
---|
| 26 | + struct perf_cpu_map *cpus; |
---|
| 27 | + struct evsel *evsel; |
---|
25 | 28 | unsigned int nr_openat_calls = 111, i; |
---|
26 | 29 | cpu_set_t cpu_set; |
---|
27 | | - struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); |
---|
| 30 | + struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); |
---|
28 | 31 | char sbuf[STRERR_BUFSIZE]; |
---|
29 | 32 | char errbuf[BUFSIZ]; |
---|
30 | 33 | |
---|
.. | .. |
---|
33 | 36 | return -1; |
---|
34 | 37 | } |
---|
35 | 38 | |
---|
36 | | - cpus = cpu_map__new(NULL); |
---|
| 39 | + cpus = perf_cpu_map__new(NULL); |
---|
37 | 40 | if (cpus == NULL) { |
---|
38 | | - pr_debug("cpu_map__new\n"); |
---|
| 41 | + pr_debug("perf_cpu_map__new\n"); |
---|
39 | 42 | goto out_thread_map_delete; |
---|
40 | 43 | } |
---|
41 | 44 | |
---|
42 | 45 | CPU_ZERO(&cpu_set); |
---|
43 | 46 | |
---|
44 | | - evsel = perf_evsel__newtp("syscalls", "sys_enter_openat"); |
---|
| 47 | + evsel = evsel__newtp("syscalls", "sys_enter_openat"); |
---|
45 | 48 | if (IS_ERR(evsel)) { |
---|
46 | 49 | tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat"); |
---|
47 | 50 | pr_debug("%s\n", errbuf); |
---|
48 | 51 | goto out_cpu_map_delete; |
---|
49 | 52 | } |
---|
50 | 53 | |
---|
51 | | - if (perf_evsel__open(evsel, cpus, threads) < 0) { |
---|
| 54 | + if (evsel__open(evsel, cpus, threads) < 0) { |
---|
52 | 55 | pr_debug("failed to open counter: %s, " |
---|
53 | 56 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
---|
54 | 57 | str_error_r(errno, sbuf, sizeof(sbuf))); |
---|
.. | .. |
---|
87 | 90 | * we use the auto allocation it will allocate just for 1 cpu, |
---|
88 | 91 | * as we start by cpu 0. |
---|
89 | 92 | */ |
---|
90 | | - if (perf_evsel__alloc_counts(evsel, cpus->nr, 1) < 0) { |
---|
91 | | - pr_debug("perf_evsel__alloc_counts(ncpus=%d)\n", cpus->nr); |
---|
| 93 | + if (evsel__alloc_counts(evsel, cpus->nr, 1) < 0) { |
---|
| 94 | + pr_debug("evsel__alloc_counts(ncpus=%d)\n", cpus->nr); |
---|
92 | 95 | goto out_close_fd; |
---|
93 | 96 | } |
---|
94 | 97 | |
---|
.. | .. |
---|
100 | 103 | if (cpus->map[cpu] >= CPU_SETSIZE) |
---|
101 | 104 | continue; |
---|
102 | 105 | |
---|
103 | | - if (perf_evsel__read_on_cpu(evsel, cpu, 0) < 0) { |
---|
104 | | - pr_debug("perf_evsel__read_on_cpu\n"); |
---|
| 106 | + if (evsel__read_on_cpu(evsel, cpu, 0) < 0) { |
---|
| 107 | + pr_debug("evsel__read_on_cpu\n"); |
---|
105 | 108 | err = -1; |
---|
106 | 109 | break; |
---|
107 | 110 | } |
---|
108 | 111 | |
---|
109 | 112 | expected = nr_openat_calls + cpu; |
---|
110 | 113 | if (perf_counts(evsel->counts, cpu, 0)->val != expected) { |
---|
111 | | - pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n", |
---|
| 114 | + pr_debug("evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n", |
---|
112 | 115 | expected, cpus->map[cpu], perf_counts(evsel->counts, cpu, 0)->val); |
---|
113 | 116 | err = -1; |
---|
114 | 117 | } |
---|
115 | 118 | } |
---|
116 | 119 | |
---|
117 | | - perf_evsel__free_counts(evsel); |
---|
| 120 | + evsel__free_counts(evsel); |
---|
118 | 121 | out_close_fd: |
---|
119 | | - perf_evsel__close_fd(evsel); |
---|
| 122 | + perf_evsel__close_fd(&evsel->core); |
---|
120 | 123 | out_evsel_delete: |
---|
121 | | - perf_evsel__delete(evsel); |
---|
| 124 | + evsel__delete(evsel); |
---|
122 | 125 | out_cpu_map_delete: |
---|
123 | | - cpu_map__put(cpus); |
---|
| 126 | + perf_cpu_map__put(cpus); |
---|
124 | 127 | out_thread_map_delete: |
---|
125 | | - thread_map__put(threads); |
---|
| 128 | + perf_thread_map__put(threads); |
---|
126 | 129 | return err; |
---|
127 | 130 | } |
---|