15 #define NR_LOOPS 10000000 26 u64 total_periods = 0;
32 struct perf_event_attr attr = {
33 .type = PERF_TYPE_SOFTWARE,
35 .sample_type = PERF_SAMPLE_PERIOD,
44 attr.sample_freq = 500;
55 goto out_delete_evlist;
61 if (!cpus || !threads) {
63 pr_debug(
"Not enough memory to create thread/cpu maps\n");
73 const char *knob =
"/proc/sys/kernel/perf_event_max_sample_rate";
76 pr_debug(
"Couldn't open evlist: %s\nHint: check %s, using %" PRIu64
" in this test.\n",
77 str_error_r(errno, sbuf,
sizeof(sbuf)),
78 knob, (u64)attr.sample_freq);
79 goto out_delete_evlist;
84 pr_debug(
"failed to mmap event: %d (%s)\n", errno,
85 str_error_r(errno, sbuf,
sizeof(sbuf)));
86 goto out_delete_evlist;
97 md = &evlist->
mmap[0];
104 if (event->
header.type != PERF_RECORD_SAMPLE)
109 pr_debug(
"Error during parse sample\n");
110 goto out_delete_evlist;
113 total_periods += sample.
period;
121 if ((u64) nr_samples == total_periods) {
122 pr_debug(
"All (%d) samples have period value of 1!\n",
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)
struct cpu_map * cpu_map__dummy_new(void)
void perf_evlist__enable(struct perf_evlist *evlist)
void perf_evlist__delete(struct perf_evlist *evlist)
struct thread_map * thread_map__new_by_tid(pid_t tid)
int test__sw_clock_freq(struct test *test __maybe_unused, int subtest __maybe_unused)
void cpu_map__put(struct cpu_map *map)
int perf_mmap__read_init(struct perf_mmap *map)
#define pr_debug(fmt,...)
int perf_evlist__open(struct perf_evlist *evlist)
int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, struct perf_sample *sample)
void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry)
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages)
static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
static struct thread_data threads[THREADS]
static struct perf_evsel * perf_evsel__new(struct perf_event_attr *attr)
void perf_mmap__read_done(struct perf_mmap *map)
struct perf_event_header header
union perf_event * perf_mmap__read_event(struct perf_mmap *map)
void perf_evlist__disable(struct perf_evlist *evlist)
void thread_map__put(struct thread_map *map)
struct perf_evlist * perf_evlist__new(void)