diff options
Diffstat (limited to 'tools/perf/tests/sw-clock.c')
-rw-r--r-- | tools/perf/tests/sw-clock.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index 2e41e2d32ccc..6664a7cd828c 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include "util/cpumap.h" | 9 | #include "util/cpumap.h" |
10 | #include "util/thread_map.h" | 10 | #include "util/thread_map.h" |
11 | 11 | ||
12 | #define NR_LOOPS 1000000 | 12 | #define NR_LOOPS 10000000 |
13 | 13 | ||
14 | /* | 14 | /* |
15 | * This test will open software clock events (cpu-clock, task-clock) | 15 | * This test will open software clock events (cpu-clock, task-clock) |
@@ -34,7 +34,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
34 | .freq = 1, | 34 | .freq = 1, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | attr.sample_freq = 10000; | 37 | attr.sample_freq = 500; |
38 | 38 | ||
39 | evlist = perf_evlist__new(); | 39 | evlist = perf_evlist__new(); |
40 | if (evlist == NULL) { | 40 | if (evlist == NULL) { |
@@ -42,7 +42,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
42 | return -1; | 42 | return -1; |
43 | } | 43 | } |
44 | 44 | ||
45 | evsel = perf_evsel__new(&attr, 0); | 45 | evsel = perf_evsel__new(&attr); |
46 | if (evsel == NULL) { | 46 | if (evsel == NULL) { |
47 | pr_debug("perf_evsel__new\n"); | 47 | pr_debug("perf_evsel__new\n"); |
48 | goto out_free_evlist; | 48 | goto out_free_evlist; |
@@ -57,7 +57,14 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
57 | goto out_delete_maps; | 57 | goto out_delete_maps; |
58 | } | 58 | } |
59 | 59 | ||
60 | perf_evlist__open(evlist); | 60 | if (perf_evlist__open(evlist)) { |
61 | const char *knob = "/proc/sys/kernel/perf_event_max_sample_rate"; | ||
62 | |||
63 | err = -errno; | ||
64 | pr_debug("Couldn't open evlist: %s\nHint: check %s, using %" PRIu64 " in this test.\n", | ||
65 | strerror(errno), knob, (u64)attr.sample_freq); | ||
66 | goto out_delete_maps; | ||
67 | } | ||
61 | 68 | ||
62 | err = perf_evlist__mmap(evlist, 128, true); | 69 | err = perf_evlist__mmap(evlist, 128, true); |
63 | if (err < 0) { | 70 | if (err < 0) { |
@@ -78,7 +85,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
78 | struct perf_sample sample; | 85 | struct perf_sample sample; |
79 | 86 | ||
80 | if (event->header.type != PERF_RECORD_SAMPLE) | 87 | if (event->header.type != PERF_RECORD_SAMPLE) |
81 | continue; | 88 | goto next_event; |
82 | 89 | ||
83 | err = perf_evlist__parse_sample(evlist, event, &sample); | 90 | err = perf_evlist__parse_sample(evlist, event, &sample); |
84 | if (err < 0) { | 91 | if (err < 0) { |
@@ -88,6 +95,8 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
88 | 95 | ||
89 | total_periods += sample.period; | 96 | total_periods += sample.period; |
90 | nr_samples++; | 97 | nr_samples++; |
98 | next_event: | ||
99 | perf_evlist__mmap_consume(evlist, 0); | ||
91 | } | 100 | } |
92 | 101 | ||
93 | if ((u64) nr_samples == total_periods) { | 102 | if ((u64) nr_samples == total_periods) { |