Skip to contentSkip to conversation

perf evlist: Add perf_evlist__parse_sample_timestamp function

tip:perf/core tip-bot for Jiri Olsa 1 participant 1 message Nov 18, 2017 perf events

lore
Share & tools
lore

tip-bot for Jiri Olsa

author merge bot
#0 lore raw
Commit-ID:  014681208ea0d1a7e5ea2f014242e7d196d04c34
Gitweb:     https://git.kernel.org/tip/014681208ea0d1a7e5ea2f014242e7d196d04c34
Author:     Jiri Olsa <[email protected]>
AuthorDate: Thu, 3 Aug 2017 13:10:28 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Nov 2017 14:50:09 -0300

perf evlist: Add perf_evlist__parse_sample_timestamp function

Add perf_evlist__parse_sample_timestamp to retrieve the timestamp of the sample.

The idea is to use this function instead of the full sample parsing before we queue the sample. At that time only the timestamp is needed and we parse the sample once again later on delivery.

---
 tools/perf/util/evlist.c | 11 ++++++++
 tools/perf/util/evlist.h |  4 +++
 tools/perf/util/evsel.c  | 65 +++++++++++++++++++++++++++++++++++++++++++-----
 tools/perf/util/evsel.h  |  4 +++
 4 files changed, 78 insertions(+), 6 deletions(-)
tools/perf/util/evlist.c +11 -0
index b62e523..199bb82 100644
@@ -1582,6 +1582,17 @@ int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *even
 	return perf_evsel__parse_sample(evsel, event, sample);
 }
 
+int perf_evlist__parse_sample_timestamp(struct perf_evlist *evlist,
+					union perf_event *event,
+					u64 *timestamp)
+{
+	struct perf_evsel *evsel = perf_evlist__event2evsel(evlist, event);
+
+	if (!evsel)
+		return -EFAULT;
+	return perf_evsel__parse_sample_timestamp(evsel, event, timestamp);
+}
+
 size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp)
 {
 	struct perf_evsel *evsel;
tools/perf/util/evlist.h +4 -0
index 491f695..4e8131d 100644
@@ -205,6 +205,10 @@ u16 perf_evlist__id_hdr_size(struct perf_evlist *evlist);
 int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event,
 			      struct perf_sample *sample);
 
+int perf_evlist__parse_sample_timestamp(struct perf_evlist *evlist,
+					union perf_event *event,
+					u64 *timestamp);
+
 bool perf_evlist__valid_sample_type(struct perf_evlist *evlist);
 bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist);
 bool perf_evlist__valid_read_format(struct perf_evlist *evlist);
tools/perf/util/evsel.c +59 -6

83 lines not on this page · raw message

tools/perf/util/evsel.h +4 -0
index 0688880..c3663a7 100644
@@ -338,6 +338,10 @@ static inline int perf_evsel__read_on_cpu_scaled(struct perf_evsel *evsel,
 int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
 			     struct perf_sample *sample);
 
+int perf_evsel__parse_sample_timestamp(struct perf_evsel *evsel,
+				       union perf_event *event,
+				       u64 *timestamp);
+
 static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel)
 {
 	return list_entry(evsel->node.next, struct perf_evsel, node);