Skip to contentSkip to conversation

perf machine: Carve up event processing specific from perf_tool

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Oct 9, 2012 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  b0a7d1a0cd2e228dc06d099db2e1bb02f1b7d591
Gitweb:     http://git.kernel.org/tip/b0a7d1a0cd2e228dc06d099db2e1bb02f1b7d591
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Sat, 6 Oct 2012 16:26:02 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Sat, 6 Oct 2012 16:34:13 -0300

perf machine: Carve up event processing specific from perf_tool

The perf_tool vtable expects methods that receive perf_tool and perf_sample entries, but for tools not interested in doing any special processing on non PERF_RECORD_SAMPLE events, like 'perf top', and for those not using perf_session, like 'perf trace', they were using perf_event__process passing tool and sample paramenters that were just not used.

Provide 'machine' methods for this purpose and make the perf_event ones use them.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-top.c  |    3 +-
 tools/perf/util/event.c   |  211 +++----------------------------------------
 tools/perf/util/machine.c |  220 +++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/machine.h |    8 ++
 4 files changed, 242 insertions(+), 200 deletions(-)
tools/perf/builtin-top.c +2 -1
index ff6db80..fb9da71 100644
@@ -26,6 +26,7 @@
 #include "util/color.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
+#include "util/machine.h"
 #include "util/session.h"
 #include "util/symbol.h"
 #include "util/thread.h"
@@ -871,7 +872,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
 						   &sample, machine);
 		} else if (event->header.type < PERF_RECORD_MAX) {
 			hists__inc_nr_events(&evsel->hists, event->header.type);
-			perf_event__process(&top->tool, event, &sample, machine);
+			machine__process_event(machine, event);
 		} else
 			++session->hists.stats.nr_unknown_events;
 	}
tools/perf/util/event.c +12 -199

252 lines not on this page · raw message

tools/perf/util/machine.c +220 -0

226 lines not on this page · raw message

tools/perf/util/machine.h +8 -0
index 54df0cd..df152f1 100644
@@ -5,7 +5,15 @@
 
 struct thread;
 struct machine;
+union perf_event;
 
 struct thread *machine__find_thread(struct machine *machine, pid_t pid);
 
+int machine__process_comm_event(struct machine *machine, union perf_event *event);
+int machine__process_exit_event(struct machine *machine, union perf_event *event);
+int machine__process_fork_event(struct machine *machine, union perf_event *event);
+int machine__process_lost_event(struct machine *machine, union perf_event *event);
+int machine__process_mmap_event(struct machine *machine, union perf_event *event);
+int machine__process_event(struct machine *machine, union perf_event *event);
+
 #endif /* __PERF_MACHINE_H */