aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-12-25 09:12:25 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-12-25 09:12:25 -0500
commita43d3f08c64125edbdfdc3d3aa512d3e37321f37 (patch)
tree3d8a2e82045f13c0b1e1fe67601c632002882e93 /tools
parent765532c8aaac624b5f8687af6d319c6a1138a257 (diff)
perf record: Fix use of sample_id_all userspace with !sample_id_all kernels
Check if parse_single_tracepoint_event has already asked for PERF_SAMPLE_TIME. This is kludgy but short term fix for problems introduced by eac23d1c that broke 'perf script' by having different sample_types when using multiple tracepoint events when we use a perf binary that tries to use sample_id_all on an older kernel. We need to move counter creation to perf_session, support different sample_types, etc. Ongoing work on the perf test infrastructure needs this so that we can create counters to monitor threads generating specific events, etc. 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> Cc: Torok Edwin <edwintorok@gmail.com> Cc: Ian Munsie <imunsie@au1.ibm.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-record.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 5149e3deb7bc..50efbd509b8f 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -243,6 +243,19 @@ static void create_counter(int counter, int cpu)
243 u64 time_running; 243 u64 time_running;
244 u64 id; 244 u64 id;
245 } read_data; 245 } read_data;
246 /*
247 * Check if parse_single_tracepoint_event has already asked for
248 * PERF_SAMPLE_TIME.
249 *
250 * XXX this is kludgy but short term fix for problems introduced by
251 * eac23d1c that broke 'perf script' by having different sample_types
252 * when using multiple tracepoint events when we use a perf binary
253 * that tries to use sample_id_all on an older kernel.
254 *
255 * We need to move counter creation to perf_session, support
256 * different sample_types, etc.
257 */
258 bool time_needed = attr->sample_type & PERF_SAMPLE_TIME;
246 259
247 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | 260 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
248 PERF_FORMAT_TOTAL_TIME_RUNNING | 261 PERF_FORMAT_TOTAL_TIME_RUNNING |
@@ -285,7 +298,8 @@ static void create_counter(int counter, int cpu)
285 if (system_wide) 298 if (system_wide)
286 attr->sample_type |= PERF_SAMPLE_CPU; 299 attr->sample_type |= PERF_SAMPLE_CPU;
287 300
288 if (sample_time || system_wide || !no_inherit || cpu_list) 301 if (sample_id_all_avail &&
302 (sample_time || system_wide || !no_inherit || cpu_list))
289 attr->sample_type |= PERF_SAMPLE_TIME; 303 attr->sample_type |= PERF_SAMPLE_TIME;
290 304
291 if (raw_samples) { 305 if (raw_samples) {
@@ -294,9 +308,6 @@ static void create_counter(int counter, int cpu)
294 attr->sample_type |= PERF_SAMPLE_CPU; 308 attr->sample_type |= PERF_SAMPLE_CPU;
295 } 309 }
296 310
297 if (!sample_type)
298 sample_type = attr->sample_type;
299
300 attr->mmap = track; 311 attr->mmap = track;
301 attr->comm = track; 312 attr->comm = track;
302 attr->inherit = !no_inherit; 313 attr->inherit = !no_inherit;
@@ -327,7 +338,7 @@ try_again:
327 * Old kernel, no attr->sample_id_type_all field 338 * Old kernel, no attr->sample_id_type_all field
328 */ 339 */
329 sample_id_all_avail = false; 340 sample_id_all_avail = false;
330 if (!sample_time && !raw_samples) 341 if (!sample_time && !raw_samples && !time_needed)
331 attr->sample_type &= ~PERF_SAMPLE_TIME; 342 attr->sample_type &= ~PERF_SAMPLE_TIME;
332 343
333 goto retry_sample_id; 344 goto retry_sample_id;
@@ -428,6 +439,9 @@ try_again:
428 } 439 }
429 } 440 }
430 } 441 }
442
443 if (!sample_type)
444 sample_type = attr->sample_type;
431} 445}
432 446
433static void open_counters(int cpu) 447static void open_counters(int cpu)