.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
---|
2 | 2 | #include <linux/compiler.h> |
---|
| 3 | +#include <linux/string.h> |
---|
3 | 4 | #include <errno.h> |
---|
4 | 5 | #include <inttypes.h> |
---|
5 | 6 | #include <string.h> |
---|
6 | 7 | #include <sys/wait.h> |
---|
| 8 | +#include <perf/cpumap.h> |
---|
7 | 9 | #include "tests.h" |
---|
8 | 10 | #include "evlist.h" |
---|
9 | 11 | #include "evsel.h" |
---|
10 | | -#include "util.h" |
---|
11 | 12 | #include "debug.h" |
---|
| 13 | +#include "parse-events.h" |
---|
12 | 14 | #include "thread_map.h" |
---|
13 | 15 | #include "target.h" |
---|
14 | 16 | |
---|
15 | | -static int attach__enable_on_exec(struct perf_evlist *evlist) |
---|
| 17 | +static int attach__enable_on_exec(struct evlist *evlist) |
---|
16 | 18 | { |
---|
17 | | - struct perf_evsel *evsel = perf_evlist__last(evlist); |
---|
| 19 | + struct evsel *evsel = evlist__last(evlist); |
---|
18 | 20 | struct target target = { |
---|
19 | 21 | .uid = UINT_MAX, |
---|
20 | 22 | }; |
---|
.. | .. |
---|
36 | 38 | return err; |
---|
37 | 39 | } |
---|
38 | 40 | |
---|
39 | | - evsel->attr.enable_on_exec = 1; |
---|
| 41 | + evsel->core.attr.enable_on_exec = 1; |
---|
40 | 42 | |
---|
41 | | - err = perf_evlist__open(evlist); |
---|
| 43 | + err = evlist__open(evlist); |
---|
42 | 44 | if (err < 0) { |
---|
43 | 45 | pr_debug("perf_evlist__open: %s\n", |
---|
44 | 46 | str_error_r(errno, sbuf, sizeof(sbuf))); |
---|
.. | .. |
---|
48 | 50 | return perf_evlist__start_workload(evlist) == 1 ? TEST_OK : TEST_FAIL; |
---|
49 | 51 | } |
---|
50 | 52 | |
---|
51 | | -static int detach__enable_on_exec(struct perf_evlist *evlist) |
---|
| 53 | +static int detach__enable_on_exec(struct evlist *evlist) |
---|
52 | 54 | { |
---|
53 | 55 | waitpid(evlist->workload.pid, NULL, 0); |
---|
54 | 56 | return 0; |
---|
55 | 57 | } |
---|
56 | 58 | |
---|
57 | | -static int attach__current_disabled(struct perf_evlist *evlist) |
---|
| 59 | +static int attach__current_disabled(struct evlist *evlist) |
---|
58 | 60 | { |
---|
59 | | - struct perf_evsel *evsel = perf_evlist__last(evlist); |
---|
60 | | - struct thread_map *threads; |
---|
| 61 | + struct evsel *evsel = evlist__last(evlist); |
---|
| 62 | + struct perf_thread_map *threads; |
---|
61 | 63 | int err; |
---|
62 | 64 | |
---|
63 | 65 | pr_debug("attaching to current thread as disabled\n"); |
---|
.. | .. |
---|
68 | 70 | return -1; |
---|
69 | 71 | } |
---|
70 | 72 | |
---|
71 | | - evsel->attr.disabled = 1; |
---|
| 73 | + evsel->core.attr.disabled = 1; |
---|
72 | 74 | |
---|
73 | | - err = perf_evsel__open_per_thread(evsel, threads); |
---|
| 75 | + err = evsel__open_per_thread(evsel, threads); |
---|
74 | 76 | if (err) { |
---|
75 | 77 | pr_debug("Failed to open event cpu-clock:u\n"); |
---|
76 | 78 | return err; |
---|
77 | 79 | } |
---|
78 | 80 | |
---|
79 | | - thread_map__put(threads); |
---|
80 | | - return perf_evsel__enable(evsel) == 0 ? TEST_OK : TEST_FAIL; |
---|
| 81 | + perf_thread_map__put(threads); |
---|
| 82 | + return evsel__enable(evsel) == 0 ? TEST_OK : TEST_FAIL; |
---|
81 | 83 | } |
---|
82 | 84 | |
---|
83 | | -static int attach__current_enabled(struct perf_evlist *evlist) |
---|
| 85 | +static int attach__current_enabled(struct evlist *evlist) |
---|
84 | 86 | { |
---|
85 | | - struct perf_evsel *evsel = perf_evlist__last(evlist); |
---|
86 | | - struct thread_map *threads; |
---|
| 87 | + struct evsel *evsel = evlist__last(evlist); |
---|
| 88 | + struct perf_thread_map *threads; |
---|
87 | 89 | int err; |
---|
88 | 90 | |
---|
89 | 91 | pr_debug("attaching to current thread as enabled\n"); |
---|
.. | .. |
---|
94 | 96 | return -1; |
---|
95 | 97 | } |
---|
96 | 98 | |
---|
97 | | - err = perf_evsel__open_per_thread(evsel, threads); |
---|
| 99 | + err = evsel__open_per_thread(evsel, threads); |
---|
98 | 100 | |
---|
99 | | - thread_map__put(threads); |
---|
| 101 | + perf_thread_map__put(threads); |
---|
100 | 102 | return err == 0 ? TEST_OK : TEST_FAIL; |
---|
101 | 103 | } |
---|
102 | 104 | |
---|
103 | | -static int detach__disable(struct perf_evlist *evlist) |
---|
| 105 | +static int detach__disable(struct evlist *evlist) |
---|
104 | 106 | { |
---|
105 | | - struct perf_evsel *evsel = perf_evlist__last(evlist); |
---|
| 107 | + struct evsel *evsel = evlist__last(evlist); |
---|
106 | 108 | |
---|
107 | | - return perf_evsel__enable(evsel); |
---|
| 109 | + return evsel__enable(evsel); |
---|
108 | 110 | } |
---|
109 | 111 | |
---|
110 | | -static int attach__cpu_disabled(struct perf_evlist *evlist) |
---|
| 112 | +static int attach__cpu_disabled(struct evlist *evlist) |
---|
111 | 113 | { |
---|
112 | | - struct perf_evsel *evsel = perf_evlist__last(evlist); |
---|
113 | | - struct cpu_map *cpus; |
---|
| 114 | + struct evsel *evsel = evlist__last(evlist); |
---|
| 115 | + struct perf_cpu_map *cpus; |
---|
114 | 116 | int err; |
---|
115 | 117 | |
---|
116 | 118 | pr_debug("attaching to CPU 0 as enabled\n"); |
---|
117 | 119 | |
---|
118 | | - cpus = cpu_map__new("0"); |
---|
| 120 | + cpus = perf_cpu_map__new("0"); |
---|
119 | 121 | if (cpus == NULL) { |
---|
120 | | - pr_debug("failed to call cpu_map__new\n"); |
---|
| 122 | + pr_debug("failed to call perf_cpu_map__new\n"); |
---|
121 | 123 | return -1; |
---|
122 | 124 | } |
---|
123 | 125 | |
---|
124 | | - evsel->attr.disabled = 1; |
---|
| 126 | + evsel->core.attr.disabled = 1; |
---|
125 | 127 | |
---|
126 | | - err = perf_evsel__open_per_cpu(evsel, cpus); |
---|
| 128 | + err = evsel__open_per_cpu(evsel, cpus, -1); |
---|
127 | 129 | if (err) { |
---|
128 | 130 | if (err == -EACCES) |
---|
129 | 131 | return TEST_SKIP; |
---|
.. | .. |
---|
132 | 134 | return err; |
---|
133 | 135 | } |
---|
134 | 136 | |
---|
135 | | - cpu_map__put(cpus); |
---|
136 | | - return perf_evsel__enable(evsel); |
---|
| 137 | + perf_cpu_map__put(cpus); |
---|
| 138 | + return evsel__enable(evsel); |
---|
137 | 139 | } |
---|
138 | 140 | |
---|
139 | | -static int attach__cpu_enabled(struct perf_evlist *evlist) |
---|
| 141 | +static int attach__cpu_enabled(struct evlist *evlist) |
---|
140 | 142 | { |
---|
141 | | - struct perf_evsel *evsel = perf_evlist__last(evlist); |
---|
142 | | - struct cpu_map *cpus; |
---|
| 143 | + struct evsel *evsel = evlist__last(evlist); |
---|
| 144 | + struct perf_cpu_map *cpus; |
---|
143 | 145 | int err; |
---|
144 | 146 | |
---|
145 | 147 | pr_debug("attaching to CPU 0 as enabled\n"); |
---|
146 | 148 | |
---|
147 | | - cpus = cpu_map__new("0"); |
---|
| 149 | + cpus = perf_cpu_map__new("0"); |
---|
148 | 150 | if (cpus == NULL) { |
---|
149 | | - pr_debug("failed to call cpu_map__new\n"); |
---|
| 151 | + pr_debug("failed to call perf_cpu_map__new\n"); |
---|
150 | 152 | return -1; |
---|
151 | 153 | } |
---|
152 | 154 | |
---|
153 | | - err = perf_evsel__open_per_cpu(evsel, cpus); |
---|
| 155 | + err = evsel__open_per_cpu(evsel, cpus, -1); |
---|
154 | 156 | if (err == -EACCES) |
---|
155 | 157 | return TEST_SKIP; |
---|
156 | 158 | |
---|
157 | | - cpu_map__put(cpus); |
---|
| 159 | + perf_cpu_map__put(cpus); |
---|
158 | 160 | return err ? TEST_FAIL : TEST_OK; |
---|
159 | 161 | } |
---|
160 | 162 | |
---|
161 | | -static int test_times(int (attach)(struct perf_evlist *), |
---|
162 | | - int (detach)(struct perf_evlist *)) |
---|
| 163 | +static int test_times(int (attach)(struct evlist *), |
---|
| 164 | + int (detach)(struct evlist *)) |
---|
163 | 165 | { |
---|
164 | 166 | struct perf_counts_values count; |
---|
165 | | - struct perf_evlist *evlist = NULL; |
---|
166 | | - struct perf_evsel *evsel; |
---|
| 167 | + struct evlist *evlist = NULL; |
---|
| 168 | + struct evsel *evsel; |
---|
167 | 169 | int err = -1, i; |
---|
168 | 170 | |
---|
169 | | - evlist = perf_evlist__new(); |
---|
| 171 | + evlist = evlist__new(); |
---|
170 | 172 | if (!evlist) { |
---|
171 | 173 | pr_debug("failed to create event list\n"); |
---|
172 | 174 | goto out_err; |
---|
.. | .. |
---|
178 | 180 | goto out_err; |
---|
179 | 181 | } |
---|
180 | 182 | |
---|
181 | | - evsel = perf_evlist__last(evlist); |
---|
182 | | - evsel->attr.read_format |= |
---|
| 183 | + evsel = evlist__last(evlist); |
---|
| 184 | + evsel->core.attr.read_format |= |
---|
183 | 185 | PERF_FORMAT_TOTAL_TIME_ENABLED | |
---|
184 | 186 | PERF_FORMAT_TOTAL_TIME_RUNNING; |
---|
185 | 187 | |
---|
.. | .. |
---|
195 | 197 | |
---|
196 | 198 | TEST_ASSERT_VAL("failed to detach", !detach(evlist)); |
---|
197 | 199 | |
---|
198 | | - perf_evsel__read(evsel, 0, 0, &count); |
---|
| 200 | + perf_evsel__read(&evsel->core, 0, 0, &count); |
---|
199 | 201 | |
---|
200 | 202 | err = !(count.ena == count.run); |
---|
201 | 203 | |
---|
.. | .. |
---|
204 | 206 | count.ena, count.run); |
---|
205 | 207 | |
---|
206 | 208 | out_err: |
---|
207 | | - perf_evlist__delete(evlist); |
---|
| 209 | + evlist__delete(evlist); |
---|
208 | 210 | return !err ? TEST_OK : TEST_FAIL; |
---|
209 | 211 | } |
---|
210 | 212 | |
---|