From 1f626bc36847ac8dd192f055aed0f9678a781313 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Sun, 9 May 2010 19:57:08 -0300 Subject: perf session: Embed the host machine data on perf_session MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have just one host on a given session, and that is the most common setup right now, so embed a ->host_machine struct machine instance directly in the perf_session class, check if we're looking for it before going to the rb_tree. This also fixes a problem found when we try to process old perf.data files where we didn't have MMAP events for the kernel and modules and thus don't create the kernel maps, do it in event__preprocess_sample if it wasn't already. Reported-by: Ingo Molnar Cc: Frédéric Weisbecker Cc: Mike Galbraith Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Tom Zanussi Cc: Zhang, Yanmin LKML-Reference: Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/session.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'tools/perf/util/session.h') diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index f2b2c6a3a49d..eb9f179376a5 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -25,6 +25,7 @@ struct perf_session { unsigned long mmap_window; struct rb_root threads; struct thread *last_match; + struct machine host_machine; struct rb_root machines; struct events_stats events_stats; struct rb_root stats_by_id; @@ -107,18 +108,22 @@ int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, static inline struct machine *perf_session__find_host_machine(struct perf_session *self) { - return machines__find_host(&self->machines); + return &self->host_machine; } static inline struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) { + if (pid == HOST_KERNEL_ID) + return &self->host_machine; return machines__find(&self->machines, pid); } static inline struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) { + if (pid == HOST_KERNEL_ID) + return &self->host_machine; return machines__findnew(&self->machines, pid); } @@ -126,14 +131,11 @@ static inline void perf_session__process_machines(struct perf_session *self, machine__process_t process) { + process(&self->host_machine, self); return machines__process(&self->machines, process, self); } -static inline -size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp) -{ - return machines__fprintf_dsos(&self->machines, fp); -} +size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); static inline size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp, -- cgit v1.2.3