diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-09 18:57:08 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-09 20:14:52 -0400 |
commit | 1f626bc36847ac8dd192f055aed0f9678a781313 (patch) | |
tree | d96b43c56217fb1ec7adaf4a9e12e11a61d0ce44 /tools | |
parent | 4cc4945844fe2cf493f1783b6ce938ba1617d5c2 (diff) |
perf session: Embed the host machine data on perf_session
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 <mingo@elte.hu>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Zhang, Yanmin <yanmin_zhang@linux.intel.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/event.c | 10 | ||||
-rw-r--r-- | tools/perf/util/map.c | 24 | ||||
-rw-r--r-- | tools/perf/util/session.c | 8 | ||||
-rw-r--r-- | tools/perf/util/session.h | 14 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 2 |
6 files changed, 29 insertions, 31 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index dfc8bf64d70f..d2ea9dd9fdf1 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -656,6 +656,16 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session, | |||
656 | goto out_filtered; | 656 | goto out_filtered; |
657 | 657 | ||
658 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); | 658 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); |
659 | /* | ||
660 | * Have we already created the kernel maps for the host machine? | ||
661 | * | ||
662 | * This should have happened earlier, when we processed the kernel MMAP | ||
663 | * events, but for older perf.data files there was no such thing, so do | ||
664 | * it now. | ||
665 | */ | ||
666 | if (cpumode == PERF_RECORD_MISC_KERNEL && | ||
667 | session->host_machine.vmlinux_maps[MAP__FUNCTION] == NULL) | ||
668 | machine__create_kernel_maps(&session->host_machine); | ||
659 | 669 | ||
660 | thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, | 670 | thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, |
661 | self->ip.pid, self->ip.ip, al); | 671 | self->ip.pid, self->ip.ip, al); |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 44a4df68b3cf..e672f2fef65b 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -579,30 +579,6 @@ struct machine *machines__find(struct rb_root *self, pid_t pid) | |||
579 | return default_machine; | 579 | return default_machine; |
580 | } | 580 | } |
581 | 581 | ||
582 | /* | ||
583 | * FIXME: Why repeatedly search for this? | ||
584 | */ | ||
585 | struct machine *machines__find_host(struct rb_root *self) | ||
586 | { | ||
587 | struct rb_node **p = &self->rb_node; | ||
588 | struct rb_node *parent = NULL; | ||
589 | struct machine *machine; | ||
590 | pid_t pid = HOST_KERNEL_ID; | ||
591 | |||
592 | while (*p != NULL) { | ||
593 | parent = *p; | ||
594 | machine = rb_entry(parent, struct machine, rb_node); | ||
595 | if (pid < machine->pid) | ||
596 | p = &(*p)->rb_left; | ||
597 | else if (pid > machine->pid) | ||
598 | p = &(*p)->rb_right; | ||
599 | else | ||
600 | return machine; | ||
601 | } | ||
602 | |||
603 | return NULL; | ||
604 | } | ||
605 | |||
606 | struct machine *machines__findnew(struct rb_root *self, pid_t pid) | 582 | struct machine *machines__findnew(struct rb_root *self, pid_t pid) |
607 | { | 583 | { |
608 | char path[PATH_MAX]; | 584 | char path[PATH_MAX]; |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 5d353e70fe26..71bc608e0ec6 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -100,6 +100,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc | |||
100 | self->repipe = repipe; | 100 | self->repipe = repipe; |
101 | self->ordered_samples.flush_limit = ULLONG_MAX; | 101 | self->ordered_samples.flush_limit = ULLONG_MAX; |
102 | INIT_LIST_HEAD(&self->ordered_samples.samples_head); | 102 | INIT_LIST_HEAD(&self->ordered_samples.samples_head); |
103 | machine__init(&self->host_machine, "", HOST_KERNEL_ID); | ||
103 | 104 | ||
104 | if (mode == O_RDONLY) { | 105 | if (mode == O_RDONLY) { |
105 | if (perf_session__open(self, force) < 0) | 106 | if (perf_session__open(self, force) < 0) |
@@ -870,3 +871,10 @@ int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps, | |||
870 | 871 | ||
871 | return 0; | 872 | return 0; |
872 | } | 873 | } |
874 | |||
875 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp) | ||
876 | { | ||
877 | return __dsos__fprintf(&self->host_machine.kernel_dsos, fp) + | ||
878 | __dsos__fprintf(&self->host_machine.user_dsos, fp) + | ||
879 | machines__fprintf_dsos(&self->machines, fp); | ||
880 | } | ||
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 { | |||
25 | unsigned long mmap_window; | 25 | unsigned long mmap_window; |
26 | struct rb_root threads; | 26 | struct rb_root threads; |
27 | struct thread *last_match; | 27 | struct thread *last_match; |
28 | struct machine host_machine; | ||
28 | struct rb_root machines; | 29 | struct rb_root machines; |
29 | struct events_stats events_stats; | 30 | struct events_stats events_stats; |
30 | struct rb_root stats_by_id; | 31 | struct rb_root stats_by_id; |
@@ -107,18 +108,22 @@ int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, | |||
107 | static inline | 108 | static inline |
108 | struct machine *perf_session__find_host_machine(struct perf_session *self) | 109 | struct machine *perf_session__find_host_machine(struct perf_session *self) |
109 | { | 110 | { |
110 | return machines__find_host(&self->machines); | 111 | return &self->host_machine; |
111 | } | 112 | } |
112 | 113 | ||
113 | static inline | 114 | static inline |
114 | struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) | 115 | struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) |
115 | { | 116 | { |
117 | if (pid == HOST_KERNEL_ID) | ||
118 | return &self->host_machine; | ||
116 | return machines__find(&self->machines, pid); | 119 | return machines__find(&self->machines, pid); |
117 | } | 120 | } |
118 | 121 | ||
119 | static inline | 122 | static inline |
120 | struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) | 123 | struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) |
121 | { | 124 | { |
125 | if (pid == HOST_KERNEL_ID) | ||
126 | return &self->host_machine; | ||
122 | return machines__findnew(&self->machines, pid); | 127 | return machines__findnew(&self->machines, pid); |
123 | } | 128 | } |
124 | 129 | ||
@@ -126,14 +131,11 @@ static inline | |||
126 | void perf_session__process_machines(struct perf_session *self, | 131 | void perf_session__process_machines(struct perf_session *self, |
127 | machine__process_t process) | 132 | machine__process_t process) |
128 | { | 133 | { |
134 | process(&self->host_machine, self); | ||
129 | return machines__process(&self->machines, process, self); | 135 | return machines__process(&self->machines, process, self); |
130 | } | 136 | } |
131 | 137 | ||
132 | static inline | 138 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); |
133 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp) | ||
134 | { | ||
135 | return machines__fprintf_dsos(&self->machines, fp); | ||
136 | } | ||
137 | 139 | ||
138 | static inline | 140 | static inline |
139 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp, | 141 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp, |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 4c0146a49063..994efdb531e4 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1889,7 +1889,7 @@ struct dso *__dsos__findnew(struct list_head *head, const char *name) | |||
1889 | return dso; | 1889 | return dso; |
1890 | } | 1890 | } |
1891 | 1891 | ||
1892 | static size_t __dsos__fprintf(struct list_head *head, FILE *fp) | 1892 | size_t __dsos__fprintf(struct list_head *head, FILE *fp) |
1893 | { | 1893 | { |
1894 | struct dso *pos; | 1894 | struct dso *pos; |
1895 | size_t ret = 0; | 1895 | size_t ret = 0; |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index a517c17407b7..edff866d76b2 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -167,6 +167,8 @@ int machine__load_kallsyms(struct machine *self, const char *filename, | |||
167 | int machine__load_vmlinux_path(struct machine *self, enum map_type type, | 167 | int machine__load_vmlinux_path(struct machine *self, enum map_type type, |
168 | symbol_filter_t filter); | 168 | symbol_filter_t filter); |
169 | 169 | ||
170 | size_t __dsos__fprintf(struct list_head *head, FILE *fp); | ||
171 | |||
170 | size_t machines__fprintf_dsos(struct rb_root *self, FILE *fp); | 172 | size_t machines__fprintf_dsos(struct rb_root *self, FILE *fp); |
171 | size_t machines__fprintf_dsos_buildid(struct rb_root *self, FILE *fp, bool with_hits); | 173 | size_t machines__fprintf_dsos_buildid(struct rb_root *self, FILE *fp, bool with_hits); |
172 | 174 | ||