diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-11 21:08:18 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-22 16:56:29 -0500 |
commit | 9d04f1781772e11bd58806391555fc23ebb54377 (patch) | |
tree | 9b91c767bed360fcfd2ab6b90794cca784db279f /tools | |
parent | f08199d314458610d4ca52f8e86e0a4ec7a7bc54 (diff) |
perf evsel: Allow specifying if the inherit bit should be set
As this is a per-cpu attribute, we can't set it up in advance and use it
for all the calls.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-stat.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-test.c | 4 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 16 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 6 |
4 files changed, 16 insertions, 14 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index b5fe522f11dc..e2a2d02c5c43 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -169,7 +169,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel) | |||
169 | PERF_FORMAT_TOTAL_TIME_RUNNING; | 169 | PERF_FORMAT_TOTAL_TIME_RUNNING; |
170 | 170 | ||
171 | if (system_wide) | 171 | if (system_wide) |
172 | return perf_evsel__open_per_cpu(evsel, cpus, false); | 172 | return perf_evsel__open_per_cpu(evsel, cpus, false, false); |
173 | 173 | ||
174 | attr->inherit = !no_inherit; | 174 | attr->inherit = !no_inherit; |
175 | if (target_pid == -1 && target_tid == -1) { | 175 | if (target_pid == -1 && target_tid == -1) { |
@@ -177,7 +177,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel) | |||
177 | attr->enable_on_exec = 1; | 177 | attr->enable_on_exec = 1; |
178 | } | 178 | } |
179 | 179 | ||
180 | return perf_evsel__open_per_thread(evsel, threads, false); | 180 | return perf_evsel__open_per_thread(evsel, threads, false, false); |
181 | } | 181 | } |
182 | 182 | ||
183 | /* | 183 | /* |
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 4282d671b161..7287158c4830 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -289,7 +289,7 @@ static int test__open_syscall_event(void) | |||
289 | goto out_thread_map_delete; | 289 | goto out_thread_map_delete; |
290 | } | 290 | } |
291 | 291 | ||
292 | if (perf_evsel__open_per_thread(evsel, threads, false) < 0) { | 292 | if (perf_evsel__open_per_thread(evsel, threads, false, false) < 0) { |
293 | pr_debug("failed to open counter: %s, " | 293 | pr_debug("failed to open counter: %s, " |
294 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", | 294 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
295 | strerror(errno)); | 295 | strerror(errno)); |
@@ -364,7 +364,7 @@ static int test__open_syscall_event_on_all_cpus(void) | |||
364 | goto out_thread_map_delete; | 364 | goto out_thread_map_delete; |
365 | } | 365 | } |
366 | 366 | ||
367 | if (perf_evsel__open(evsel, cpus, threads, false) < 0) { | 367 | if (perf_evsel__open(evsel, cpus, threads, false, false) < 0) { |
368 | pr_debug("failed to open counter: %s, " | 368 | pr_debug("failed to open counter: %s, " |
369 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", | 369 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
370 | strerror(errno)); | 370 | strerror(errno)); |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index da473ec93c75..82a00536892a 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -128,7 +128,7 @@ int __perf_evsel__read(struct perf_evsel *evsel, | |||
128 | } | 128 | } |
129 | 129 | ||
130 | static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | 130 | static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, |
131 | struct thread_map *threads, bool group) | 131 | struct thread_map *threads, bool group, bool inherit) |
132 | { | 132 | { |
133 | int cpu, thread; | 133 | int cpu, thread; |
134 | 134 | ||
@@ -139,6 +139,8 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | |||
139 | for (cpu = 0; cpu < cpus->nr; cpu++) { | 139 | for (cpu = 0; cpu < cpus->nr; cpu++) { |
140 | int group_fd = -1; | 140 | int group_fd = -1; |
141 | 141 | ||
142 | evsel->attr.inherit = (cpus->map[cpu] < 0) && inherit; | ||
143 | |||
142 | for (thread = 0; thread < threads->nr; thread++) { | 144 | for (thread = 0; thread < threads->nr; thread++) { |
143 | FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr, | 145 | FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr, |
144 | threads->map[thread], | 146 | threads->map[thread], |
@@ -182,7 +184,7 @@ static struct { | |||
182 | }; | 184 | }; |
183 | 185 | ||
184 | int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | 186 | int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, |
185 | struct thread_map *threads, bool group) | 187 | struct thread_map *threads, bool group, bool inherit) |
186 | { | 188 | { |
187 | if (cpus == NULL) { | 189 | if (cpus == NULL) { |
188 | /* Work around old compiler warnings about strict aliasing */ | 190 | /* Work around old compiler warnings about strict aliasing */ |
@@ -192,17 +194,17 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | |||
192 | if (threads == NULL) | 194 | if (threads == NULL) |
193 | threads = &empty_thread_map.map; | 195 | threads = &empty_thread_map.map; |
194 | 196 | ||
195 | return __perf_evsel__open(evsel, cpus, threads, group); | 197 | return __perf_evsel__open(evsel, cpus, threads, group, inherit); |
196 | } | 198 | } |
197 | 199 | ||
198 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, | 200 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, |
199 | struct cpu_map *cpus, bool group) | 201 | struct cpu_map *cpus, bool group, bool inherit) |
200 | { | 202 | { |
201 | return __perf_evsel__open(evsel, cpus, &empty_thread_map.map, group); | 203 | return __perf_evsel__open(evsel, cpus, &empty_thread_map.map, group, inherit); |
202 | } | 204 | } |
203 | 205 | ||
204 | int perf_evsel__open_per_thread(struct perf_evsel *evsel, | 206 | int perf_evsel__open_per_thread(struct perf_evsel *evsel, |
205 | struct thread_map *threads, bool group) | 207 | struct thread_map *threads, bool group, bool inherit) |
206 | { | 208 | { |
207 | return __perf_evsel__open(evsel, &empty_cpu_map.map, threads, group); | 209 | return __perf_evsel__open(evsel, &empty_cpu_map.map, threads, group, inherit); |
208 | } | 210 | } |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 0962b500cb6d..1594696bd127 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -46,11 +46,11 @@ void perf_evsel__free_fd(struct perf_evsel *evsel); | |||
46 | void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads); | 46 | void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads); |
47 | 47 | ||
48 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, | 48 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, |
49 | struct cpu_map *cpus, bool group); | 49 | struct cpu_map *cpus, bool group, bool inherit); |
50 | int perf_evsel__open_per_thread(struct perf_evsel *evsel, | 50 | int perf_evsel__open_per_thread(struct perf_evsel *evsel, |
51 | struct thread_map *threads, bool group); | 51 | struct thread_map *threads, bool group, bool inherit); |
52 | int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | 52 | int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, |
53 | struct thread_map *threads, bool group); | 53 | struct thread_map *threads, bool group, bool inherit); |
54 | 54 | ||
55 | #define perf_evsel__match(evsel, t, c) \ | 55 | #define perf_evsel__match(evsel, t, c) \ |
56 | (evsel->attr.type == PERF_TYPE_##t && \ | 56 | (evsel->attr.type == PERF_TYPE_##t && \ |