12 #include <linux/err.h> 13 #include <linux/kernel.h> 34 const char *syscall_names[] = {
"getsid",
"getppid",
"getpgid", };
35 pid_t (*
syscalls[])(void) = { (
void *)getsid, getppid, (
void*)getpgid };
36 #define nsyscalls ARRAY_SIZE(syscall_names) 44 if (threads == NULL) {
52 goto out_free_threads;
56 CPU_SET(cpus->
map[0], &cpu_set);
57 sched_setaffinity(0,
sizeof(cpu_set), &cpu_set);
58 if (sched_setaffinity(0,
sizeof(cpu_set), &cpu_set) < 0) {
59 pr_debug(
"sched_setaffinity() failed on CPU %d: %s ",
60 cpus->
map[0], str_error_r(errno, sbuf,
sizeof(sbuf)));
75 snprintf(name,
sizeof(name),
"sys_enter_%s", syscall_names[i]);
77 if (IS_ERR(evsels[i])) {
78 pr_debug(
"perf_evsel__new(%s)\n", name);
79 goto out_delete_evlist;
82 evsels[i]->
attr.wakeup_events = 1;
88 pr_debug(
"failed to open counter: %s, " 89 "tweak /proc/sys/kernel/perf_event_paranoid?\n",
90 str_error_r(errno, sbuf,
sizeof(sbuf)));
91 goto out_delete_evlist;
95 expected_nr_events[i] = 1 + rand() % 127;
99 pr_debug(
"failed to mmap events: %d (%s)\n", errno,
100 str_error_r(errno, sbuf,
sizeof(sbuf)));
101 goto out_delete_evlist;
105 for (j = 0; j < expected_nr_events[i]; ++j) {
110 md = &evlist->
mmap[0];
117 if (event->
header.type != PERF_RECORD_SAMPLE) {
120 goto out_delete_evlist;
125 pr_err(
"Can't parse sample, err = %d\n", err);
126 goto out_delete_evlist;
133 " doesn't map to an evsel\n", sample.
id);
134 goto out_delete_evlist;
136 nr_events[evsel->
idx]++;
144 if (nr_events[evsel->
idx] != expected_nr_events[evsel->
idx]) {
145 pr_debug(
"expected %d %s events, got %d\n",
146 expected_nr_events[evsel->
idx],
149 goto out_delete_evlist;
void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus, struct thread_map *threads)
void perf_mmap__consume(struct perf_mmap *map)
int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unused)
void perf_evlist__delete(struct perf_evlist *evlist)
void cpu_map__put(struct cpu_map *map)
int perf_mmap__read_init(struct perf_mmap *map)
#define pr_debug(fmt,...)
#define evlist__for_each_entry(evlist, evsel)
int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, struct perf_sample *sample)
struct perf_evsel * perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry)
const char * perf_event__name(unsigned int id)
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages)
const char * perf_evsel__name(struct perf_evsel *evsel)
static struct thread_data threads[THREADS]
void perf_mmap__read_done(struct perf_mmap *map)
struct perf_event_header header
int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, struct thread_map *threads)
union perf_event * perf_mmap__read_event(struct perf_mmap *map)
void perf_evsel__set_sample_id(struct perf_evsel *evsel, bool can_sample_identifier)
void thread_map__put(struct thread_map *map)
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)
struct perf_evlist * perf_evlist__new(void)
struct perf_event_attr attr