diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-03 11:02:24 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-12 11:39:51 -0400 |
commit | 4a6b362f36e68618ee4d3cdb361d05a5e80af023 (patch) | |
tree | d4857d28733a0ae160b793835cf290a068abdb2a /tools | |
parent | 01fbc1fee926888f7c256ada95fa5fa3b06cba94 (diff) |
perf ordered_events: Adopt queue() method
From perf_session, will be used in 'trace'.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-mfihndzaumx44h6y37ng2irb@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/ordered-events.c | 34 | ||||
-rw-r--r-- | tools/perf/util/ordered-events.h | 4 | ||||
-rw-r--r-- | tools/perf/util/session.c | 28 |
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 | ||
134 | struct ordered_event * | 134 | static struct ordered_event * |
135 | ordered_events__new(struct ordered_events *oe, u64 timestamp, | 135 | ordered_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 | ||
156 | int 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 | |||
156 | static int __ordered_events__flush(struct ordered_events *oe) | 186 | static 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 | ||
52 | struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp, | 52 | int ordered_events__queue(struct ordered_events *oe, union perf_event *event, |
53 | union perf_event *event); | 53 | struct perf_sample *sample, u64 file_offset); |
54 | void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); | 54 | void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); |
55 | int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); | 55 | int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); |
56 | void ordered_events__init(struct ordered_events *oe, struct machines *machines, | 56 | void 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, | |||
541 | int perf_session__queue_event(struct perf_session *s, union perf_event *event, | 541 | int 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 | ||
573 | static void callchain__lbr_callstack_printf(struct perf_sample *sample) | 547 | static void callchain__lbr_callstack_printf(struct perf_sample *sample) |