Skip to content

Commit

Permalink
perf record: Fix use of sample_id_all userspace with !sample_id_all k…
Browse files Browse the repository at this point in the history
…ernels

Check if parse_single_tracepoint_event has already asked for PERF_SAMPLE_TIME.

This is kludgy but short term fix for problems introduced by eac23d1 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>
  • Loading branch information
Arnaldo Carvalho de Melo committed Dec 25, 2010
1 parent 765532c commit a43d3f0
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,19 @@ static void create_counter(int counter, int cpu)
u64 time_running;
u64 id;
} read_data;
/*
* Check if parse_single_tracepoint_event has already asked for
* PERF_SAMPLE_TIME.
*
* XXX 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.
*/
bool time_needed = attr->sample_type & PERF_SAMPLE_TIME;

attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
PERF_FORMAT_TOTAL_TIME_RUNNING |
Expand Down Expand Up @@ -285,7 +298,8 @@ static void create_counter(int counter, int cpu)
if (system_wide)
attr->sample_type |= PERF_SAMPLE_CPU;

if (sample_time || system_wide || !no_inherit || cpu_list)
if (sample_id_all_avail &&
(sample_time || system_wide || !no_inherit || cpu_list))
attr->sample_type |= PERF_SAMPLE_TIME;

if (raw_samples) {
Expand All @@ -294,9 +308,6 @@ static void create_counter(int counter, int cpu)
attr->sample_type |= PERF_SAMPLE_CPU;
}

if (!sample_type)
sample_type = attr->sample_type;

attr->mmap = track;
attr->comm = track;
attr->inherit = !no_inherit;
Expand Down Expand Up @@ -327,7 +338,7 @@ static void create_counter(int counter, int cpu)
* Old kernel, no attr->sample_id_type_all field
*/
sample_id_all_avail = false;
if (!sample_time && !raw_samples)
if (!sample_time && !raw_samples && !time_needed)
attr->sample_type &= ~PERF_SAMPLE_TIME;

goto retry_sample_id;
Expand Down Expand Up @@ -428,6 +439,9 @@ static void create_counter(int counter, int cpu)
}
}
}

if (!sample_type)
sample_type = attr->sample_type;
}

static void open_counters(int cpu)
Expand Down

0 comments on commit a43d3f0

Please sign in to comment.