aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/ordered-events.c34
-rw-r--r--tools/perf/util/ordered-events.h4
-rw-r--r--tools/perf/util/session.c28
3 files changed, 35 insertions, 31 deletions
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index 0d8cea91d2c9..6002fa3fcf77 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -131,8 +131,8 @@ static struct ordered_event *alloc_event(struct ordered_events *oe,
131 return new; 131 return new;
132} 132}
133 133
134struct ordered_event * 134static struct ordered_event *
135ordered_events__new(struct ordered_events *oe, u64 timestamp, 135ordered_events__new_event(struct ordered_events *oe, u64 timestamp,
136 union perf_event *event) 136 union perf_event *event)
137{ 137{
138 struct ordered_event *new; 138 struct ordered_event *new;
@@ -153,6 +153,36 @@ void ordered_events__delete(struct ordered_events *oe, struct ordered_event *eve
153 free_dup_event(oe, event->event); 153 free_dup_event(oe, event->event);
154} 154}
155 155
156int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
157 struct perf_sample *sample, u64 file_offset)
158{
159 u64 timestamp = sample->time;
160 struct ordered_event *oevent;
161
162 if (!timestamp || timestamp == ~0ULL)
163 return -ETIME;
164
165 if (timestamp < oe->last_flush) {
166 pr_oe_time(timestamp, "out of order event\n");
167 pr_oe_time(oe->last_flush, "last flush, last_flush_type %d\n",
168 oe->last_flush_type);
169
170 oe->evlist->stats.nr_unordered_events++;
171 }
172
173 oevent = ordered_events__new_event(oe, timestamp, event);
174 if (!oevent) {
175 ordered_events__flush(oe, OE_FLUSH__HALF);
176 oevent = ordered_events__new_event(oe, timestamp, event);
177 }
178
179 if (!oevent)
180 return -ENOMEM;
181
182 oevent->file_offset = file_offset;
183 return 0;
184}
185
156static int __ordered_events__flush(struct ordered_events *oe) 186static int __ordered_events__flush(struct ordered_events *oe)
157{ 187{
158 struct list_head *head = &oe->events; 188 struct list_head *head = &oe->events;
diff --git a/tools/perf/util/ordered-events.h b/tools/perf/util/ordered-events.h
index c6cf0bafbb2c..173e13f28c08 100644
--- a/tools/perf/util/ordered-events.h
+++ b/tools/perf/util/ordered-events.h
@@ -49,8 +49,8 @@ struct ordered_events {
49 bool copy_on_queue; 49 bool copy_on_queue;
50}; 50};
51 51
52struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp, 52int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
53 union perf_event *event); 53 struct perf_sample *sample, u64 file_offset);
54void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); 54void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
55int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); 55int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
56void ordered_events__init(struct ordered_events *oe, struct machines *machines, 56void ordered_events__init(struct ordered_events *oe, struct machines *machines,
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 703a370ae5b6..adf0740c563b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -541,33 +541,7 @@ static int process_finished_round(struct perf_tool *tool __maybe_unused,
541int perf_session__queue_event(struct perf_session *s, union perf_event *event, 541int perf_session__queue_event(struct perf_session *s, union perf_event *event,
542 struct perf_sample *sample, u64 file_offset) 542 struct perf_sample *sample, u64 file_offset)
543{ 543{
544 struct ordered_events *oe = &s->ordered_events; 544 return ordered_events__queue(&s->ordered_events, event, sample, file_offset);
545
546 u64 timestamp = sample->time;
547 struct ordered_event *new;
548
549 if (!timestamp || timestamp == ~0ULL)
550 return -ETIME;
551
552 if (timestamp < oe->last_flush) {
553 pr_oe_time(timestamp, "out of order event\n");
554 pr_oe_time(oe->last_flush, "last flush, last_flush_type %d\n",
555 oe->last_flush_type);
556
557 s->evlist->stats.nr_unordered_events++;
558 }
559
560 new = ordered_events__new(oe, timestamp, event);
561 if (!new) {
562 ordered_events__flush(oe, OE_FLUSH__HALF);
563 new = ordered_events__new(oe, timestamp, event);
564 }
565
566 if (!new)
567 return -ENOMEM;
568
569 new->file_offset = file_offset;
570 return 0;
571} 545}
572 546
573static void callchain__lbr_callstack_printf(struct perf_sample *sample) 547static void callchain__lbr_callstack_printf(struct perf_sample *sample)