diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-11 11:50:36 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-12 01:42:09 -0500 |
commit | 9958e1f0aee632c3665162c9c93cf8fde8006a94 (patch) | |
tree | ffd81c34d3ca8044c3fe0d670dc1786113624bbb /tools/perf/util/thread.h | |
parent | 58e9f94138c1d9c47f6a63632ca7a78fc6dcc15f (diff) |
perf symbols: Rename kthreads to kmaps, using another abstraction for it
Using a struct thread instance just to hold the kernel space maps
(vmlinux + modules) is overkill and confuses people trying to
understand the perf symbols abstractions.
The kernel maps are really present in all threads, i.e. the kernel
is a library, not a separate thread.
So introduce the 'map_groups' abstraction and use it for the kernel
maps, now in the kmaps global variable.
It, in turn, will move, together with the threads list to the
perf_file abstraction, so that we can support multiple perf_file
instances, needed by perf diff.
Brainstormed-with: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260550239-5372-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/thread.h')
-rw-r--r-- | tools/perf/util/thread.h | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 686d6e914d9e..a6333f3716af 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h | |||
@@ -5,52 +5,63 @@ | |||
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | #include "symbol.h" | 6 | #include "symbol.h" |
7 | 7 | ||
8 | struct thread { | 8 | struct map_groups { |
9 | struct rb_node rb_node; | ||
10 | struct rb_root maps[MAP__NR_TYPES]; | 9 | struct rb_root maps[MAP__NR_TYPES]; |
11 | struct list_head removed_maps[MAP__NR_TYPES]; | 10 | struct list_head removed_maps[MAP__NR_TYPES]; |
12 | pid_t pid; | ||
13 | bool use_modules; | 11 | bool use_modules; |
12 | }; | ||
13 | |||
14 | struct thread { | ||
15 | struct rb_node rb_node; | ||
16 | struct map_groups mg; | ||
17 | pid_t pid; | ||
14 | char shortname[3]; | 18 | char shortname[3]; |
15 | char *comm; | 19 | char *comm; |
16 | int comm_len; | 20 | int comm_len; |
17 | }; | 21 | }; |
18 | 22 | ||
19 | void thread__init(struct thread *self, pid_t pid); | 23 | void map_groups__init(struct map_groups *self); |
20 | int thread__set_comm(struct thread *self, const char *comm); | 24 | int thread__set_comm(struct thread *self, const char *comm); |
21 | int thread__comm_len(struct thread *self); | 25 | int thread__comm_len(struct thread *self); |
22 | struct thread *threads__findnew(pid_t pid); | 26 | struct thread *threads__findnew(pid_t pid); |
23 | struct thread *register_idle_thread(void); | 27 | struct thread *register_idle_thread(void); |
24 | void thread__insert_map(struct thread *self, struct map *map); | 28 | void thread__insert_map(struct thread *self, struct map *map); |
25 | int thread__fork(struct thread *self, struct thread *parent); | 29 | int thread__fork(struct thread *self, struct thread *parent); |
26 | size_t thread__fprintf_maps(struct thread *self, FILE *fp); | 30 | size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp); |
27 | size_t threads__fprintf(FILE *fp); | 31 | size_t threads__fprintf(FILE *fp); |
28 | 32 | ||
29 | void maps__insert(struct rb_root *maps, struct map *map); | 33 | void maps__insert(struct rb_root *maps, struct map *map); |
30 | struct map *maps__find(struct rb_root *maps, u64 addr); | 34 | struct map *maps__find(struct rb_root *maps, u64 addr); |
31 | 35 | ||
32 | static inline struct map *thread__find_map(struct thread *self, | 36 | static inline void map_groups__insert(struct map_groups *self, struct map *map) |
37 | { | ||
38 | maps__insert(&self->maps[map->type], map); | ||
39 | } | ||
40 | |||
41 | static inline struct map *map_groups__find(struct map_groups *self, | ||
33 | enum map_type type, u64 addr) | 42 | enum map_type type, u64 addr) |
34 | { | 43 | { |
35 | return self ? maps__find(&self->maps[type], addr) : NULL; | 44 | return maps__find(&self->maps[type], addr); |
36 | } | 45 | } |
37 | 46 | ||
38 | static inline void __thread__insert_map(struct thread *self, struct map *map) | 47 | static inline struct map *thread__find_map(struct thread *self, |
48 | enum map_type type, u64 addr) | ||
39 | { | 49 | { |
40 | maps__insert(&self->maps[map->type], map); | 50 | return self ? map_groups__find(&self->mg, type, addr) : NULL; |
41 | } | 51 | } |
42 | 52 | ||
43 | void thread__find_addr_location(struct thread *self, u8 cpumode, | 53 | void thread__find_addr_location(struct thread *self, u8 cpumode, |
44 | enum map_type type, u64 addr, | 54 | enum map_type type, u64 addr, |
45 | struct addr_location *al, | 55 | struct addr_location *al, |
46 | symbol_filter_t filter); | 56 | symbol_filter_t filter); |
47 | struct symbol *thread__find_symbol(struct thread *self, | 57 | struct symbol *map_groups__find_symbol(struct map_groups *self, |
48 | enum map_type type, u64 addr, | 58 | enum map_type type, u64 addr, |
49 | symbol_filter_t filter); | 59 | symbol_filter_t filter); |
50 | 60 | ||
51 | static inline struct symbol * | 61 | static inline struct symbol * |
52 | thread__find_function(struct thread *self, u64 addr, symbol_filter_t filter) | 62 | map_groups__find_function(struct map_groups *self, u64 addr, |
63 | symbol_filter_t filter) | ||
53 | { | 64 | { |
54 | return thread__find_symbol(self, MAP__FUNCTION, addr, filter); | 65 | return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter); |
55 | } | 66 | } |
56 | #endif /* __PERF_THREAD_H */ | 67 | #endif /* __PERF_THREAD_H */ |