diff options
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r-- | tools/perf/builtin-record.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 024e1441d76b..699dd2149c4b 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -36,6 +36,7 @@ static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; | |||
36 | 36 | ||
37 | static u64 user_interval = ULLONG_MAX; | 37 | static u64 user_interval = ULLONG_MAX; |
38 | static u64 default_interval = 0; | 38 | static u64 default_interval = 0; |
39 | static u64 sample_type; | ||
39 | 40 | ||
40 | static int nr_cpus = 0; | 41 | static int nr_cpus = 0; |
41 | static unsigned int page_size; | 42 | static unsigned int page_size; |
@@ -48,6 +49,7 @@ static const char *output_name = "perf.data"; | |||
48 | static int group = 0; | 49 | static int group = 0; |
49 | static int realtime_prio = 0; | 50 | static int realtime_prio = 0; |
50 | static bool raw_samples = false; | 51 | static bool raw_samples = false; |
52 | static bool sample_id_all_avail = true; | ||
51 | static bool system_wide = false; | 53 | static bool system_wide = false; |
52 | static pid_t target_pid = -1; | 54 | static pid_t target_pid = -1; |
53 | static pid_t target_tid = -1; | 55 | static pid_t target_tid = -1; |
@@ -60,6 +62,7 @@ static bool call_graph = false; | |||
60 | static bool inherit_stat = false; | 62 | static bool inherit_stat = false; |
61 | static bool no_samples = false; | 63 | static bool no_samples = false; |
62 | static bool sample_address = false; | 64 | static bool sample_address = false; |
65 | static bool sample_time = false; | ||
63 | static bool no_buildid = false; | 66 | static bool no_buildid = false; |
64 | static bool no_buildid_cache = false; | 67 | static bool no_buildid_cache = false; |
65 | 68 | ||
@@ -129,6 +132,7 @@ static void write_output(void *buf, size_t size) | |||
129 | } | 132 | } |
130 | 133 | ||
131 | static int process_synthesized_event(event_t *event, | 134 | static int process_synthesized_event(event_t *event, |
135 | struct sample_data *sample __used, | ||
132 | struct perf_session *self __used) | 136 | struct perf_session *self __used) |
133 | { | 137 | { |
134 | write_output(event, event->header.size); | 138 | write_output(event, event->header.size); |
@@ -281,12 +285,18 @@ static void create_counter(int counter, int cpu) | |||
281 | if (system_wide) | 285 | if (system_wide) |
282 | attr->sample_type |= PERF_SAMPLE_CPU; | 286 | attr->sample_type |= PERF_SAMPLE_CPU; |
283 | 287 | ||
288 | if (sample_time) | ||
289 | attr->sample_type |= PERF_SAMPLE_TIME; | ||
290 | |||
284 | if (raw_samples) { | 291 | if (raw_samples) { |
285 | attr->sample_type |= PERF_SAMPLE_TIME; | 292 | attr->sample_type |= PERF_SAMPLE_TIME; |
286 | attr->sample_type |= PERF_SAMPLE_RAW; | 293 | attr->sample_type |= PERF_SAMPLE_RAW; |
287 | attr->sample_type |= PERF_SAMPLE_CPU; | 294 | attr->sample_type |= PERF_SAMPLE_CPU; |
288 | } | 295 | } |
289 | 296 | ||
297 | if (!sample_type) | ||
298 | sample_type = attr->sample_type; | ||
299 | |||
290 | attr->mmap = track; | 300 | attr->mmap = track; |
291 | attr->comm = track; | 301 | attr->comm = track; |
292 | attr->inherit = !no_inherit; | 302 | attr->inherit = !no_inherit; |
@@ -294,6 +304,8 @@ static void create_counter(int counter, int cpu) | |||
294 | attr->disabled = 1; | 304 | attr->disabled = 1; |
295 | attr->enable_on_exec = 1; | 305 | attr->enable_on_exec = 1; |
296 | } | 306 | } |
307 | retry_sample_id: | ||
308 | attr->sample_id_all = sample_id_all_avail ? 1 : 0; | ||
297 | 309 | ||
298 | for (thread_index = 0; thread_index < thread_num; thread_index++) { | 310 | for (thread_index = 0; thread_index < thread_num; thread_index++) { |
299 | try_again: | 311 | try_again: |
@@ -310,6 +322,12 @@ try_again: | |||
310 | else if (err == ENODEV && cpu_list) { | 322 | else if (err == ENODEV && cpu_list) { |
311 | die("No such device - did you specify" | 323 | die("No such device - did you specify" |
312 | " an out-of-range profile CPU?\n"); | 324 | " an out-of-range profile CPU?\n"); |
325 | } else if (err == EINVAL && sample_id_all_avail) { | ||
326 | /* | ||
327 | * Old kernel, no attr->sample_id_type_all field | ||
328 | */ | ||
329 | sample_id_all_avail = false; | ||
330 | goto retry_sample_id; | ||
313 | } | 331 | } |
314 | 332 | ||
315 | /* | 333 | /* |
@@ -642,6 +660,8 @@ static int __cmd_record(int argc, const char **argv) | |||
642 | open_counters(cpumap[i]); | 660 | open_counters(cpumap[i]); |
643 | } | 661 | } |
644 | 662 | ||
663 | perf_session__set_sample_type(session, sample_type); | ||
664 | |||
645 | if (pipe_output) { | 665 | if (pipe_output) { |
646 | err = perf_header__write_pipe(output); | 666 | err = perf_header__write_pipe(output); |
647 | if (err < 0) | 667 | if (err < 0) |
@@ -654,6 +674,8 @@ static int __cmd_record(int argc, const char **argv) | |||
654 | 674 | ||
655 | post_processing_offset = lseek(output, 0, SEEK_CUR); | 675 | post_processing_offset = lseek(output, 0, SEEK_CUR); |
656 | 676 | ||
677 | perf_session__set_sample_id_all(session, sample_id_all_avail); | ||
678 | |||
657 | if (pipe_output) { | 679 | if (pipe_output) { |
658 | err = event__synthesize_attrs(&session->header, | 680 | err = event__synthesize_attrs(&session->header, |
659 | process_synthesized_event, | 681 | process_synthesized_event, |
@@ -834,6 +856,7 @@ const struct option record_options[] = { | |||
834 | "per thread counts"), | 856 | "per thread counts"), |
835 | OPT_BOOLEAN('d', "data", &sample_address, | 857 | OPT_BOOLEAN('d', "data", &sample_address, |
836 | "Sample addresses"), | 858 | "Sample addresses"), |
859 | OPT_BOOLEAN('T', "timestamp", &sample_time, "Sample timestamps"), | ||
837 | OPT_BOOLEAN('n', "no-samples", &no_samples, | 860 | OPT_BOOLEAN('n', "no-samples", &no_samples, |
838 | "don't sample"), | 861 | "don't sample"), |
839 | OPT_BOOLEAN('N', "no-buildid-cache", &no_buildid_cache, | 862 | OPT_BOOLEAN('N', "no-buildid-cache", &no_buildid_cache, |