hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/tools/perf/tests/openat-syscall.c
....@@ -3,6 +3,7 @@
33 #include <inttypes.h>
44 #include <api/fs/tracing_path.h>
55 #include <linux/err.h>
6
+#include <linux/string.h>
67 #include <sys/types.h>
78 #include <sys/stat.h>
89 #include <fcntl.h>
....@@ -10,13 +11,14 @@
1011 #include "evsel.h"
1112 #include "debug.h"
1213 #include "tests.h"
14
+#include "util/counts.h"
1315
1416 int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __maybe_unused)
1517 {
1618 int err = -1, fd;
17
- struct perf_evsel *evsel;
19
+ struct evsel *evsel;
1820 unsigned int nr_openat_calls = 111, i;
19
- struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
21
+ struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
2022 char sbuf[STRERR_BUFSIZE];
2123 char errbuf[BUFSIZ];
2224
....@@ -25,14 +27,14 @@
2527 return -1;
2628 }
2729
28
- evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
30
+ evsel = evsel__newtp("syscalls", "sys_enter_openat");
2931 if (IS_ERR(evsel)) {
3032 tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
3133 pr_debug("%s\n", errbuf);
3234 goto out_thread_map_delete;
3335 }
3436
35
- if (perf_evsel__open_per_thread(evsel, threads) < 0) {
37
+ if (evsel__open_per_thread(evsel, threads) < 0) {
3638 pr_debug("failed to open counter: %s, "
3739 "tweak /proc/sys/kernel/perf_event_paranoid?\n",
3840 str_error_r(errno, sbuf, sizeof(sbuf)));
....@@ -44,23 +46,23 @@
4446 close(fd);
4547 }
4648
47
- if (perf_evsel__read_on_cpu(evsel, 0, 0) < 0) {
48
- pr_debug("perf_evsel__read_on_cpu\n");
49
+ if (evsel__read_on_cpu(evsel, 0, 0) < 0) {
50
+ pr_debug("evsel__read_on_cpu\n");
4951 goto out_close_fd;
5052 }
5153
5254 if (perf_counts(evsel->counts, 0, 0)->val != nr_openat_calls) {
53
- pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n",
55
+ pr_debug("evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n",
5456 nr_openat_calls, perf_counts(evsel->counts, 0, 0)->val);
5557 goto out_close_fd;
5658 }
5759
5860 err = 0;
5961 out_close_fd:
60
- perf_evsel__close_fd(evsel);
62
+ perf_evsel__close_fd(&evsel->core);
6163 out_evsel_delete:
62
- perf_evsel__delete(evsel);
64
+ evsel__delete(evsel);
6365 out_thread_map_delete:
64
- thread_map__put(threads);
66
+ perf_thread_map__put(threads);
6567 return err;
6668 }