aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-03-03 10:20:38 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-03-12 11:39:46 -0400
commitd10eb1eb76a86266354ecab6e42c1606e3b8bc4c (patch)
treee16a15de7df6ff556375effce15d5ece48c809bd
parentb7b61cbebd789a3dbca522e3fdb727fe5c95593f (diff)
perf ordered_events: Allow tools to specify a deliver method
So that we can simplify the deliver method to pass just: (ordered_events, ordered_event, sample); 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-j0s4bpxs5qza5tnkvjwom9rw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/ordered-events.c7
-rw-r--r--tools/perf/util/ordered-events.h11
-rw-r--r--tools/perf/util/session.c30
-rw-r--r--tools/perf/util/session.h6
4 files changed, 37 insertions, 17 deletions
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index bad46ce16591..0d8cea91d2c9 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -181,8 +181,7 @@ static int __ordered_events__flush(struct ordered_events *oe)
181 if (ret) 181 if (ret)
182 pr_err("Can't parse sample, err = %d\n", ret); 182 pr_err("Can't parse sample, err = %d\n", ret);
183 else { 183 else {
184 ret = machines__deliver_event(oe->machines, oe->evlist, iter->event, 184 ret = oe->deliver(oe, iter, &sample);
185 &sample, oe->tool, iter->file_offset);
186 if (ret) 185 if (ret)
187 return ret; 186 return ret;
188 } 187 }
@@ -264,7 +263,8 @@ int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
264} 263}
265 264
266void ordered_events__init(struct ordered_events *oe, struct machines *machines, 265void ordered_events__init(struct ordered_events *oe, struct machines *machines,
267 struct perf_evlist *evlist, struct perf_tool *tool) 266 struct perf_evlist *evlist, struct perf_tool *tool,
267 ordered_events__deliver_t deliver)
268{ 268{
269 INIT_LIST_HEAD(&oe->events); 269 INIT_LIST_HEAD(&oe->events);
270 INIT_LIST_HEAD(&oe->cache); 270 INIT_LIST_HEAD(&oe->cache);
@@ -274,6 +274,7 @@ void ordered_events__init(struct ordered_events *oe, struct machines *machines,
274 oe->evlist = evlist; 274 oe->evlist = evlist;
275 oe->machines = machines; 275 oe->machines = machines;
276 oe->tool = tool; 276 oe->tool = tool;
277 oe->deliver = deliver;
277} 278}
278 279
279void ordered_events__free(struct ordered_events *oe) 280void ordered_events__free(struct ordered_events *oe)
diff --git a/tools/perf/util/ordered-events.h b/tools/perf/util/ordered-events.h
index ef7d73ecb0d0..c6cf0bafbb2c 100644
--- a/tools/perf/util/ordered-events.h
+++ b/tools/perf/util/ordered-events.h
@@ -5,6 +5,7 @@
5 5
6struct perf_tool; 6struct perf_tool;
7struct perf_evlist; 7struct perf_evlist;
8struct perf_sample;
8struct machines; 9struct machines;
9 10
10struct ordered_event { 11struct ordered_event {
@@ -21,6 +22,12 @@ enum oe_flush {
21 OE_FLUSH__HALF, 22 OE_FLUSH__HALF,
22}; 23};
23 24
25struct ordered_events;
26
27typedef int (*ordered_events__deliver_t)(struct ordered_events *oe,
28 struct ordered_event *event,
29 struct perf_sample *sample);
30
24struct ordered_events { 31struct ordered_events {
25 u64 last_flush; 32 u64 last_flush;
26 u64 next_flush; 33 u64 next_flush;
@@ -35,6 +42,7 @@ struct ordered_events {
35 struct machines *machines; 42 struct machines *machines;
36 struct perf_evlist *evlist; 43 struct perf_evlist *evlist;
37 struct perf_tool *tool; 44 struct perf_tool *tool;
45 ordered_events__deliver_t deliver;
38 int buffer_idx; 46 int buffer_idx;
39 unsigned int nr_events; 47 unsigned int nr_events;
40 enum oe_flush last_flush_type; 48 enum oe_flush last_flush_type;
@@ -46,7 +54,8 @@ struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timesta
46void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event); 54void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
47int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); 55int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
48void ordered_events__init(struct ordered_events *oe, struct machines *machines, 56void ordered_events__init(struct ordered_events *oe, struct machines *machines,
49 struct perf_evlist *evlsit, struct perf_tool *tool); 57 struct perf_evlist *evlsit, struct perf_tool *tool,
58 ordered_events__deliver_t deliver);
50void ordered_events__free(struct ordered_events *oe); 59void ordered_events__free(struct ordered_events *oe);
51 60
52static inline 61static inline
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index c6dd89f62fc4..e2f318a3f17a 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -16,6 +16,12 @@
16#include "perf_regs.h" 16#include "perf_regs.h"
17#include "asm/bug.h" 17#include "asm/bug.h"
18 18
19static int machines__deliver_event(struct machines *machines,
20 struct perf_evlist *evlist,
21 union perf_event *event,
22 struct perf_sample *sample,
23 struct perf_tool *tool, u64 file_offset);
24
19static int perf_session__open(struct perf_session *session) 25static int perf_session__open(struct perf_session *session)
20{ 26{
21 struct perf_data_file *file = session->file; 27 struct perf_data_file *file = session->file;
@@ -86,6 +92,14 @@ static void perf_session__set_comm_exec(struct perf_session *session)
86 machines__set_comm_exec(&session->machines, comm_exec); 92 machines__set_comm_exec(&session->machines, comm_exec);
87} 93}
88 94
95static int ordered_events__deliver_event(struct ordered_events *oe,
96 struct ordered_event *event,
97 struct perf_sample *sample)
98{
99 return machines__deliver_event(oe->machines, oe->evlist, event->event,
100 sample, oe->tool, event->file_offset);
101}
102
89struct perf_session *perf_session__new(struct perf_data_file *file, 103struct perf_session *perf_session__new(struct perf_data_file *file,
90 bool repipe, struct perf_tool *tool) 104 bool repipe, struct perf_tool *tool)
91{ 105{
@@ -125,8 +139,10 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
125 tool->ordered_events && !perf_evlist__sample_id_all(session->evlist)) { 139 tool->ordered_events && !perf_evlist__sample_id_all(session->evlist)) {
126 dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n"); 140 dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n");
127 tool->ordered_events = false; 141 tool->ordered_events = false;
128 } else 142 } else {
129 ordered_events__init(&session->ordered_events, &session->machines, session->evlist, tool); 143 ordered_events__init(&session->ordered_events, &session->machines,
144 session->evlist, tool, ordered_events__deliver_event);
145 }
130 146
131 return session; 147 return session;
132 148
@@ -888,11 +904,11 @@ static int
888 &sample->read.one, machine); 904 &sample->read.one, machine);
889} 905}
890 906
891int machines__deliver_event(struct machines *machines, 907static int machines__deliver_event(struct machines *machines,
892 struct perf_evlist *evlist, 908 struct perf_evlist *evlist,
893 union perf_event *event, 909 union perf_event *event,
894 struct perf_sample *sample, 910 struct perf_sample *sample,
895 struct perf_tool *tool, u64 file_offset) 911 struct perf_tool *tool, u64 file_offset)
896{ 912{
897 struct perf_evsel *evsel; 913 struct perf_evsel *evsel;
898 struct machine *machine; 914 struct machine *machine;
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 06e0777e9803..1310998f8318 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -55,12 +55,6 @@ int perf_session__queue_event(struct perf_session *s, union perf_event *event,
55 55
56void perf_tool__fill_defaults(struct perf_tool *tool); 56void perf_tool__fill_defaults(struct perf_tool *tool);
57 57
58int machines__deliver_event(struct machines *machines,
59 struct perf_evlist *evlist,
60 union perf_event *event,
61 struct perf_sample *sample,
62 struct perf_tool *tool, u64 file_offset);
63
64int perf_session__resolve_callchain(struct perf_session *session, 58int perf_session__resolve_callchain(struct perf_session *session,
65 struct perf_evsel *evsel, 59 struct perf_evsel *evsel,
66 struct thread *thread, 60 struct thread *thread,