Skip to contentSkip to conversation

perf ordered_events: Add first_time() method

tip:perf/core tip-bot for Jiri Olsa 1 participant 1 message Dec 14, 2018 perf events

lore
Share & tools
lore

tip-bot for Jiri Olsa

author merge bot
#0 lore raw
Commit-ID:  5a0cb2ffce065d738d90c0bf372a79ddc961c9ff
Gitweb:     https://git.kernel.org/tip/5a0cb2ffce065d738d90c0bf372a79ddc961c9ff
Author:     Jiri Olsa <[email protected]>
AuthorDate: Thu, 6 Dec 2018 14:38:52 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 6 Dec 2018 16:43:28 -0300

perf ordered_events: Add first_time() method

To get the timestamp in the first event in the queue.

Cc Adrian Hunter <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Dmitry Levin <[email protected]>
Cc Eugene Syromiatnikov <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Luis Cláudio Gonçalves <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Thomas Gleixner <[email protected]>
[ split from a larger patch ]
---
 tools/perf/util/ordered-events.c | 11 +++++++++++
 tools/perf/util/ordered-events.h |  1 +
 2 files changed, 12 insertions(+)
tools/perf/util/ordered-events.c +11 -0
index 46965643020b..897589507d97 100644
@@ -343,6 +343,17 @@ int ordered_events__flush_time(struct ordered_events *oe, u64 timestamp)
 	return __ordered_events__flush(oe, OE_FLUSH__TIME, timestamp);
 }
 
+u64 ordered_events__first_time(struct ordered_events *oe)
+{
+	struct ordered_event *event;
+
+	if (list_empty(&oe->events))
+		return 0;
+
+	event = list_first_entry(&oe->events, struct ordered_event, list);
+	return event->timestamp;
+}
+
 void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver,
 			  void *data)
 {
tools/perf/util/ordered-events.h +1 -0
index f352af20e167..0920fb0ec6cc 100644
@@ -61,6 +61,7 @@ void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t d
 			  void *data);
 void ordered_events__free(struct ordered_events *oe);
 void ordered_events__reinit(struct ordered_events *oe);
+u64 ordered_events__first_time(struct ordered_events *oe);
 
 static inline
 void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)