forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/tools/perf/tests/openat-syscall-all-cpus.c
....@@ -9,22 +9,25 @@
99 #include <fcntl.h>
1010 #include <api/fs/fs.h>
1111 #include <linux/err.h>
12
+#include <linux/string.h>
1213 #include <api/fs/tracing_path.h>
1314 #include "evsel.h"
1415 #include "tests.h"
1516 #include "thread_map.h"
16
-#include "cpumap.h"
17
+#include <perf/cpumap.h>
18
+#include <internal/cpumap.h>
1719 #include "debug.h"
1820 #include "stat.h"
21
+#include "util/counts.h"
1922
2023 int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int subtest __maybe_unused)
2124 {
2225 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;
2528 unsigned int nr_openat_calls = 111, i;
2629 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);
2831 char sbuf[STRERR_BUFSIZE];
2932 char errbuf[BUFSIZ];
3033
....@@ -33,22 +36,22 @@
3336 return -1;
3437 }
3538
36
- cpus = cpu_map__new(NULL);
39
+ cpus = perf_cpu_map__new(NULL);
3740 if (cpus == NULL) {
38
- pr_debug("cpu_map__new\n");
41
+ pr_debug("perf_cpu_map__new\n");
3942 goto out_thread_map_delete;
4043 }
4144
4245 CPU_ZERO(&cpu_set);
4346
44
- evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
47
+ evsel = evsel__newtp("syscalls", "sys_enter_openat");
4548 if (IS_ERR(evsel)) {
4649 tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
4750 pr_debug("%s\n", errbuf);
4851 goto out_cpu_map_delete;
4952 }
5053
51
- if (perf_evsel__open(evsel, cpus, threads) < 0) {
54
+ if (evsel__open(evsel, cpus, threads) < 0) {
5255 pr_debug("failed to open counter: %s, "
5356 "tweak /proc/sys/kernel/perf_event_paranoid?\n",
5457 str_error_r(errno, sbuf, sizeof(sbuf)));
....@@ -87,8 +90,8 @@
8790 * we use the auto allocation it will allocate just for 1 cpu,
8891 * as we start by cpu 0.
8992 */
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);
9295 goto out_close_fd;
9396 }
9497
....@@ -100,28 +103,28 @@
100103 if (cpus->map[cpu] >= CPU_SETSIZE)
101104 continue;
102105
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");
105108 err = -1;
106109 break;
107110 }
108111
109112 expected = nr_openat_calls + cpu;
110113 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",
112115 expected, cpus->map[cpu], perf_counts(evsel->counts, cpu, 0)->val);
113116 err = -1;
114117 }
115118 }
116119
117
- perf_evsel__free_counts(evsel);
120
+ evsel__free_counts(evsel);
118121 out_close_fd:
119
- perf_evsel__close_fd(evsel);
122
+ perf_evsel__close_fd(&evsel->core);
120123 out_evsel_delete:
121
- perf_evsel__delete(evsel);
124
+ evsel__delete(evsel);
122125 out_cpu_map_delete:
123
- cpu_map__put(cpus);
126
+ perf_cpu_map__put(cpus);
124127 out_thread_map_delete:
125
- thread_map__put(threads);
128
+ perf_thread_map__put(threads);
126129 return err;
127130 }