aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/tests/builtin-test.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-11-09 19:46:43 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-11-14 14:49:25 -0500
commitbd90517b374b1d6381a5509f55df1a9b7c33a6b1 (patch)
treeb3b9011250f5d889b45dd997de55bb5c525c661f /tools/perf/tests/builtin-test.c
parentd3b59a38bcdab4248134023c2c5dfabee5a4878e (diff)
perf tests: Move test__open_syscall_event_on_all_cpus into separate object
Separating test__open_syscall_event_on_all_cpus test from the builtin-test into open-syscall-all-cpus object. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1352508412-16914-4-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/builtin-test.c')
-rw-r--r--tools/perf/tests/builtin-test.c114
1 files changed, 0 insertions, 114 deletions
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index b6b1e46a51c6..98e883bc330b 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -29,120 +29,6 @@
29 29
30#include <sched.h> 30#include <sched.h>
31 31
32static int test__open_syscall_event_on_all_cpus(void)
33{
34 int err = -1, fd, cpu;
35 struct thread_map *threads;
36 struct cpu_map *cpus;
37 struct perf_evsel *evsel;
38 struct perf_event_attr attr;
39 unsigned int nr_open_calls = 111, i;
40 cpu_set_t cpu_set;
41 int id = trace_event__id("sys_enter_open");
42
43 if (id < 0) {
44 pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
45 return -1;
46 }
47
48 threads = thread_map__new(-1, getpid(), UINT_MAX);
49 if (threads == NULL) {
50 pr_debug("thread_map__new\n");
51 return -1;
52 }
53
54 cpus = cpu_map__new(NULL);
55 if (cpus == NULL) {
56 pr_debug("cpu_map__new\n");
57 goto out_thread_map_delete;
58 }
59
60
61 CPU_ZERO(&cpu_set);
62
63 memset(&attr, 0, sizeof(attr));
64 attr.type = PERF_TYPE_TRACEPOINT;
65 attr.config = id;
66 evsel = perf_evsel__new(&attr, 0);
67 if (evsel == NULL) {
68 pr_debug("perf_evsel__new\n");
69 goto out_thread_map_delete;
70 }
71
72 if (perf_evsel__open(evsel, cpus, threads) < 0) {
73 pr_debug("failed to open counter: %s, "
74 "tweak /proc/sys/kernel/perf_event_paranoid?\n",
75 strerror(errno));
76 goto out_evsel_delete;
77 }
78
79 for (cpu = 0; cpu < cpus->nr; ++cpu) {
80 unsigned int ncalls = nr_open_calls + cpu;
81 /*
82 * XXX eventually lift this restriction in a way that
83 * keeps perf building on older glibc installations
84 * without CPU_ALLOC. 1024 cpus in 2010 still seems
85 * a reasonable upper limit tho :-)
86 */
87 if (cpus->map[cpu] >= CPU_SETSIZE) {
88 pr_debug("Ignoring CPU %d\n", cpus->map[cpu]);
89 continue;
90 }
91
92 CPU_SET(cpus->map[cpu], &cpu_set);
93 if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) {
94 pr_debug("sched_setaffinity() failed on CPU %d: %s ",
95 cpus->map[cpu],
96 strerror(errno));
97 goto out_close_fd;
98 }
99 for (i = 0; i < ncalls; ++i) {
100 fd = open("/etc/passwd", O_RDONLY);
101 close(fd);
102 }
103 CPU_CLR(cpus->map[cpu], &cpu_set);
104 }
105
106 /*
107 * Here we need to explicitely preallocate the counts, as if
108 * we use the auto allocation it will allocate just for 1 cpu,
109 * as we start by cpu 0.
110 */
111 if (perf_evsel__alloc_counts(evsel, cpus->nr) < 0) {
112 pr_debug("perf_evsel__alloc_counts(ncpus=%d)\n", cpus->nr);
113 goto out_close_fd;
114 }
115
116 err = 0;
117
118 for (cpu = 0; cpu < cpus->nr; ++cpu) {
119 unsigned int expected;
120
121 if (cpus->map[cpu] >= CPU_SETSIZE)
122 continue;
123
124 if (perf_evsel__read_on_cpu(evsel, cpu, 0) < 0) {
125 pr_debug("perf_evsel__read_on_cpu\n");
126 err = -1;
127 break;
128 }
129
130 expected = nr_open_calls + cpu;
131 if (evsel->counts->cpu[cpu].val != expected) {
132 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n",
133 expected, cpus->map[cpu], evsel->counts->cpu[cpu].val);
134 err = -1;
135 }
136 }
137
138out_close_fd:
139 perf_evsel__close_fd(evsel, 1, threads->nr);
140out_evsel_delete:
141 perf_evsel__delete(evsel);
142out_thread_map_delete:
143 thread_map__delete(threads);
144 return err;
145}
146 32
147/* 33/*
148 * This test will generate random numbers of calls to some getpid syscalls, 34 * This test will generate random numbers of calls to some getpid syscalls,