diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-10-13 10:16:29 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-13 11:12:18 -0400 |
commit | d5b889f2ecec7849e851ddd31c34bdfb3482b5de (patch) | |
tree | 001c95641ddf734a1e5e1fdee7e821f042c08f0b /tools/perf/builtin-annotate.c | |
parent | f4f0b418188cc7995375acbb54e87c80f21861bd (diff) |
perf tools: Move threads & last_match to threads.c
This was just being copy'n'pasted all over.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <20091013141629.GD21809@ghostprotocols.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r-- | tools/perf/builtin-annotate.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 8c84320ecb06..3fe0de03004d 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -37,10 +37,6 @@ static int print_line; | |||
37 | static unsigned long page_size; | 37 | static unsigned long page_size; |
38 | static unsigned long mmap_window = 32; | 38 | static unsigned long mmap_window = 32; |
39 | 39 | ||
40 | static struct rb_root threads; | ||
41 | static struct thread *last_match; | ||
42 | |||
43 | |||
44 | struct sym_ext { | 40 | struct sym_ext { |
45 | struct rb_node node; | 41 | struct rb_node node; |
46 | double percent; | 42 | double percent; |
@@ -96,12 +92,10 @@ static int | |||
96 | process_sample_event(event_t *event, unsigned long offset, unsigned long head) | 92 | process_sample_event(event_t *event, unsigned long offset, unsigned long head) |
97 | { | 93 | { |
98 | char level; | 94 | char level; |
99 | struct thread *thread; | ||
100 | u64 ip = event->ip.ip; | 95 | u64 ip = event->ip.ip; |
101 | struct map *map = NULL; | 96 | struct map *map = NULL; |
102 | struct symbol *sym = NULL; | 97 | struct symbol *sym = NULL; |
103 | 98 | struct thread *thread = threads__findnew(event->ip.pid); | |
104 | thread = threads__findnew(event->ip.pid, &threads, &last_match); | ||
105 | 99 | ||
106 | dump_printf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n", | 100 | dump_printf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n", |
107 | (void *)(offset + head), | 101 | (void *)(offset + head), |
@@ -166,10 +160,8 @@ got_map: | |||
166 | static int | 160 | static int |
167 | process_mmap_event(event_t *event, unsigned long offset, unsigned long head) | 161 | process_mmap_event(event_t *event, unsigned long offset, unsigned long head) |
168 | { | 162 | { |
169 | struct thread *thread; | ||
170 | struct map *map = map__new(&event->mmap, NULL, 0); | 163 | struct map *map = map__new(&event->mmap, NULL, 0); |
171 | 164 | struct thread *thread = threads__findnew(event->mmap.pid); | |
172 | thread = threads__findnew(event->mmap.pid, &threads, &last_match); | ||
173 | 165 | ||
174 | dump_printf("%p [%p]: PERF_RECORD_MMAP %d: [%p(%p) @ %p]: %s\n", | 166 | dump_printf("%p [%p]: PERF_RECORD_MMAP %d: [%p(%p) @ %p]: %s\n", |
175 | (void *)(offset + head), | 167 | (void *)(offset + head), |
@@ -194,9 +186,8 @@ process_mmap_event(event_t *event, unsigned long offset, unsigned long head) | |||
194 | static int | 186 | static int |
195 | process_comm_event(event_t *event, unsigned long offset, unsigned long head) | 187 | process_comm_event(event_t *event, unsigned long offset, unsigned long head) |
196 | { | 188 | { |
197 | struct thread *thread; | 189 | struct thread *thread = threads__findnew(event->comm.pid); |
198 | 190 | ||
199 | thread = threads__findnew(event->comm.pid, &threads, &last_match); | ||
200 | dump_printf("%p [%p]: PERF_RECORD_COMM: %s:%d\n", | 191 | dump_printf("%p [%p]: PERF_RECORD_COMM: %s:%d\n", |
201 | (void *)(offset + head), | 192 | (void *)(offset + head), |
202 | (void *)(long)(event->header.size), | 193 | (void *)(long)(event->header.size), |
@@ -215,11 +206,9 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head) | |||
215 | static int | 206 | static int |
216 | process_fork_event(event_t *event, unsigned long offset, unsigned long head) | 207 | process_fork_event(event_t *event, unsigned long offset, unsigned long head) |
217 | { | 208 | { |
218 | struct thread *thread; | 209 | struct thread *thread = threads__findnew(event->fork.pid); |
219 | struct thread *parent; | 210 | struct thread *parent = threads__findnew(event->fork.ppid); |
220 | 211 | ||
221 | thread = threads__findnew(event->fork.pid, &threads, &last_match); | ||
222 | parent = threads__findnew(event->fork.ppid, &threads, &last_match); | ||
223 | dump_printf("%p [%p]: PERF_RECORD_FORK: %d:%d\n", | 212 | dump_printf("%p [%p]: PERF_RECORD_FORK: %d:%d\n", |
224 | (void *)(offset + head), | 213 | (void *)(offset + head), |
225 | (void *)(long)(event->header.size), | 214 | (void *)(long)(event->header.size), |
@@ -558,7 +547,7 @@ static int __cmd_annotate(void) | |||
558 | uint32_t size; | 547 | uint32_t size; |
559 | char *buf; | 548 | char *buf; |
560 | 549 | ||
561 | register_idle_thread(&threads, &last_match); | 550 | register_idle_thread(); |
562 | 551 | ||
563 | input = open(input_name, O_RDONLY); | 552 | input = open(input_name, O_RDONLY); |
564 | if (input < 0) { | 553 | if (input < 0) { |
@@ -659,7 +648,7 @@ more: | |||
659 | return 0; | 648 | return 0; |
660 | 649 | ||
661 | if (verbose > 3) | 650 | if (verbose > 3) |
662 | threads__fprintf(stdout, &threads); | 651 | threads__fprintf(stdout); |
663 | 652 | ||
664 | if (verbose > 2) | 653 | if (verbose > 2) |
665 | dsos__fprintf(stdout); | 654 | dsos__fprintf(stdout); |