| .. | .. |
|---|
| 3 | 3 | #include <inttypes.h> |
|---|
| 4 | 4 | #include <api/fs/tracing_path.h> |
|---|
| 5 | 5 | #include <linux/err.h> |
|---|
| 6 | +#include <linux/string.h> |
|---|
| 6 | 7 | #include <sys/types.h> |
|---|
| 7 | 8 | #include <sys/stat.h> |
|---|
| 8 | 9 | #include <fcntl.h> |
|---|
| .. | .. |
|---|
| 10 | 11 | #include "evsel.h" |
|---|
| 11 | 12 | #include "debug.h" |
|---|
| 12 | 13 | #include "tests.h" |
|---|
| 14 | +#include "util/counts.h" |
|---|
| 13 | 15 | |
|---|
| 14 | 16 | int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __maybe_unused) |
|---|
| 15 | 17 | { |
|---|
| 16 | 18 | int err = -1, fd; |
|---|
| 17 | | - struct perf_evsel *evsel; |
|---|
| 19 | + struct evsel *evsel; |
|---|
| 18 | 20 | 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); |
|---|
| 20 | 22 | char sbuf[STRERR_BUFSIZE]; |
|---|
| 21 | 23 | char errbuf[BUFSIZ]; |
|---|
| 22 | 24 | |
|---|
| .. | .. |
|---|
| 25 | 27 | return -1; |
|---|
| 26 | 28 | } |
|---|
| 27 | 29 | |
|---|
| 28 | | - evsel = perf_evsel__newtp("syscalls", "sys_enter_openat"); |
|---|
| 30 | + evsel = evsel__newtp("syscalls", "sys_enter_openat"); |
|---|
| 29 | 31 | if (IS_ERR(evsel)) { |
|---|
| 30 | 32 | tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat"); |
|---|
| 31 | 33 | pr_debug("%s\n", errbuf); |
|---|
| 32 | 34 | goto out_thread_map_delete; |
|---|
| 33 | 35 | } |
|---|
| 34 | 36 | |
|---|
| 35 | | - if (perf_evsel__open_per_thread(evsel, threads) < 0) { |
|---|
| 37 | + if (evsel__open_per_thread(evsel, threads) < 0) { |
|---|
| 36 | 38 | pr_debug("failed to open counter: %s, " |
|---|
| 37 | 39 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
|---|
| 38 | 40 | str_error_r(errno, sbuf, sizeof(sbuf))); |
|---|
| .. | .. |
|---|
| 44 | 46 | close(fd); |
|---|
| 45 | 47 | } |
|---|
| 46 | 48 | |
|---|
| 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"); |
|---|
| 49 | 51 | goto out_close_fd; |
|---|
| 50 | 52 | } |
|---|
| 51 | 53 | |
|---|
| 52 | 54 | 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", |
|---|
| 54 | 56 | nr_openat_calls, perf_counts(evsel->counts, 0, 0)->val); |
|---|
| 55 | 57 | goto out_close_fd; |
|---|
| 56 | 58 | } |
|---|
| 57 | 59 | |
|---|
| 58 | 60 | err = 0; |
|---|
| 59 | 61 | out_close_fd: |
|---|
| 60 | | - perf_evsel__close_fd(evsel); |
|---|
| 62 | + perf_evsel__close_fd(&evsel->core); |
|---|
| 61 | 63 | out_evsel_delete: |
|---|
| 62 | | - perf_evsel__delete(evsel); |
|---|
| 64 | + evsel__delete(evsel); |
|---|
| 63 | 65 | out_thread_map_delete: |
|---|
| 64 | | - thread_map__put(threads); |
|---|
| 66 | + perf_thread_map__put(threads); |
|---|
| 65 | 67 | return err; |
|---|
| 66 | 68 | } |
|---|