diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2021-05-03 09:42:22 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2021-05-12 12:43:11 -0300 |
commit | 66286ed3e84f126a24baca3ee62635536a428950 (patch) | |
tree | 33d4a9cdd965b4b22325a468df5dec06f1f1450c /tools/perf | |
parent | e3ff42bdebcfeb5f61fcc7a769d642dfc8b923d1 (diff) | |
download | linux-66286ed3e84f126a24baca3ee62635536a428950.tar.bz2 |
perf record: Set timestamp boundary for AUX area events
AUX area data is not processed by 'perf record' and consequently the
--timestamp-boundary option may result in no values for "time of first
sample" and "time of last sample". However there are non-sample events
that can be used instead, namely 'itrace_start' and 'aux'.
'itrace_start' is issued before tracing starts, and 'aux' is issued
every time data is ready.
Implement tool callbacks for those two for 'perf record', to update the
timestamp boundary.
Example:
$ perf record -e intel_pt//u --timestamp-boundary uname
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.022 MB perf.data ]
$ perf script --header-only | grep "time of"
# time of first sample : 4574.835541
# time of last sample : 4574.835907
$ perf script --itrace=be -F-ip | head -1
uname 13752 [001] 4574.835589: 1 branches:uH:
$ perf script --itrace=be -F-ip | tail -1
uname 13752 [001] 4574.835867: 1 branches:uH:
$
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lore.kernel.org/lkml/20210503064222.5319-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-record.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3337b5f93336..bc3dd379eb67 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -969,6 +969,15 @@ out: return rc; } +static void set_timestamp_boundary(struct record *rec, u64 sample_time) +{ + if (rec->evlist->first_sample_time == 0) + rec->evlist->first_sample_time = sample_time; + + if (sample_time) + rec->evlist->last_sample_time = sample_time; +} + static int process_sample_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, @@ -977,10 +986,7 @@ static int process_sample_event(struct perf_tool *tool, { struct record *rec = container_of(tool, struct record, tool); - if (rec->evlist->first_sample_time == 0) - rec->evlist->first_sample_time = sample->time; - - rec->evlist->last_sample_time = sample->time; + set_timestamp_boundary(rec, sample->time); if (rec->buildid_all) return 0; @@ -2402,6 +2408,17 @@ static int build_id__process_mmap2(struct perf_tool *tool, union perf_event *eve return perf_event__process_mmap2(tool, event, sample, machine); } +static int process_timestamp_boundary(struct perf_tool *tool, + union perf_event *event __maybe_unused, + struct perf_sample *sample, + struct machine *machine __maybe_unused) +{ + struct record *rec = container_of(tool, struct record, tool); + + set_timestamp_boundary(rec, sample->time); + return 0; +} + /* * XXX Ideally would be local to cmd_record() and passed to a record__new * because we need to have access to it in record__exit, that is called @@ -2436,6 +2453,8 @@ static struct record record = { .namespaces = perf_event__process_namespaces, .mmap = build_id__process_mmap, .mmap2 = build_id__process_mmap2, + .itrace_start = process_timestamp_boundary, + .aux = process_timestamp_boundary, .ordered_events = true, }, }; |