10 #include <api/fs/fs.h> 11 #include <linux/err.h> 12 #include <api/fs/tracing_path.h> 25 unsigned int nr_openat_calls = 111, i;
31 if (threads == NULL) {
39 goto out_thread_map_delete;
46 tracing_path__strerror_open_tp(errno, errbuf,
sizeof(errbuf),
"syscalls",
"sys_enter_openat");
48 goto out_thread_map_delete;
52 pr_debug(
"failed to open counter: %s, " 53 "tweak /proc/sys/kernel/perf_event_paranoid?\n",
54 str_error_r(errno, sbuf,
sizeof(sbuf)));
55 goto out_evsel_delete;
58 for (cpu = 0; cpu < cpus->
nr; ++cpu) {
59 unsigned int ncalls = nr_openat_calls + cpu;
66 if (cpus->
map[cpu] >= CPU_SETSIZE) {
71 CPU_SET(cpus->
map[cpu], &cpu_set);
72 if (sched_setaffinity(0,
sizeof(cpu_set), &cpu_set) < 0) {
73 pr_debug(
"sched_setaffinity() failed on CPU %d: %s ",
75 str_error_r(errno, sbuf,
sizeof(sbuf)));
78 for (i = 0; i < ncalls; ++i) {
79 fd = openat(0,
"/etc/passwd", O_RDONLY);
82 CPU_CLR(cpus->
map[cpu], &cpu_set);
91 pr_debug(
"perf_evsel__alloc_counts(ncpus=%d)\n", cpus->
nr);
97 for (cpu = 0; cpu < cpus->
nr; ++cpu) {
98 unsigned int expected;
100 if (cpus->
map[cpu] >= CPU_SETSIZE)
104 pr_debug(
"perf_evsel__read_on_cpu\n");
109 expected = nr_openat_calls + cpu;
111 pr_debug(
"perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64
"\n",
122 out_thread_map_delete:
static int perf_evsel__read_on_cpu(struct perf_evsel *evsel, int cpu, int thread)
void perf_evsel__delete(struct perf_evsel *evsel)
#define pr_debug(fmt,...)
struct perf_counts * counts
void perf_evsel__free_counts(struct perf_evsel *evsel)
int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, struct thread_map *threads)
void perf_evsel__close_fd(struct perf_evsel *evsel)
int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
void thread_map__put(struct thread_map *map)
static struct perf_counts_values * perf_counts(struct perf_counts *counts, int cpu, int thread)
static struct perf_evsel * perf_evsel__newtp(const char *sys, const char *name)
struct thread_map * thread_map__new(pid_t pid, pid_t tid, uid_t uid)
struct cpu_map * cpu_map__new(const char *cpu_list)
int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int subtest __maybe_unused)