6 #include <linux/types.h> 17 #include "arch-tests.h" 19 #define CHECK__(x) { \ 21 pr_debug(#x " failed!\n"); \ 26 #define CHECK_NOT_NULL__(x) { \ 27 while ((x) == NULL) { \ 28 pr_debug(#x " failed!\n"); \ 45 .user_freq = UINT_MAX,
46 .user_interval = ULLONG_MAX,
57 const char *comm1, *comm2;
59 struct perf_event_mmap_page *pc;
61 u64 test_tsc, comm1_tsc, comm2_tsc;
62 u64 test_time, comm1_time = 0, comm2_time = 0;
83 evsel->
attr.disabled = 1;
84 evsel->
attr.enable_on_exec = 0;
93 if (ret == -EOPNOTSUPP) {
94 fprintf(stderr,
" (not supported)");
102 comm1 =
"Test COMM 1";
107 comm2 =
"Test COMM 2";
112 for (i = 0; i < evlist->
nr_mmaps; i++) {
113 md = &evlist->
mmap[i];
120 if (event->
header.type != PERF_RECORD_COMM ||
121 (pid_t)event->
comm.
pid != getpid() ||
122 (pid_t)event->
comm.
tid != getpid())
125 if (strcmp(event->
comm.
comm, comm1) == 0) {
128 comm1_time = sample.
time;
130 if (strcmp(event->
comm.
comm, comm2) == 0) {
133 comm2_time = sample.
time;
141 if (!comm1_time || !comm2_time)
148 pr_debug(
"1st event perf time %"PRIu64
" tsc %"PRIu64
"\n",
149 comm1_time, comm1_tsc);
150 pr_debug(
"rdtsc time %"PRIu64
" tsc %"PRIu64
"\n",
151 test_time, test_tsc);
152 pr_debug(
"2nd event perf time %"PRIu64
" tsc %"PRIu64
"\n",
153 comm2_time, comm2_tsc);
155 if (test_time <= comm1_time ||
156 test_time >= comm2_time)
159 if (test_tsc <= comm1_tsc ||
160 test_tsc >= comm2_tsc)
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)
void perf_evlist__enable(struct perf_evlist *evlist)
void perf_evlist__delete(struct perf_evlist *evlist)
int parse_events(struct perf_evlist *evlist, const char *str, struct parse_events_error *err)
int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe_unused)
int perf_mmap__read_init(struct perf_mmap *map)
#define pr_debug(fmt,...)
int perf_evlist__open(struct perf_evlist *evlist)
u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts, struct callchain_param *callchain)
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages)
void perf_mmap__read_done(struct perf_mmap *map)
struct perf_event_header header
static struct perf_evsel * perf_evlist__first(struct perf_evlist *evlist)
union perf_event * perf_mmap__read_event(struct perf_mmap *map)
void perf_evlist__disable(struct perf_evlist *evlist)
u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)
int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, struct perf_sample *data)
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)
#define CHECK_NOT_NULL__(x)
int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, struct perf_tsc_conversion *tc)
struct perf_evlist * perf_evlist__new(void)
struct perf_event_attr attr