diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2013-08-08 07:32:20 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-08-12 09:31:09 -0400 |
commit | 611a5ce8aa4cdb2daefbd9bed77ec3b3e9bd00ea (patch) | |
tree | f0eb9c834975d921c101b33bf5990f6a667f932a | |
parent | 93ea01c29d4ed5a9fcf6d9a95bc584e54a420834 (diff) |
perf machine: Add symbol filter to struct machine
The symbol filter needs to be applied machine-wide, so add it to struct
machine.
Currently tools pass the symbol filter as a parameter to various
map-related functions. However a need to load a map can occur anywhere
in the code, at which point the filter is needed.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1375961547-30267-2-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/machine.c | 20 | ||||
-rw-r--r-- | tools/perf/util/machine.h | 5 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 6fcc358138ae..4c7e0a28bf3d 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -25,6 +25,8 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) | |||
25 | machine->kmaps.machine = machine; | 25 | machine->kmaps.machine = machine; |
26 | machine->pid = pid; | 26 | machine->pid = pid; |
27 | 27 | ||
28 | machine->symbol_filter = NULL; | ||
29 | |||
28 | machine->root_dir = strdup(root_dir); | 30 | machine->root_dir = strdup(root_dir); |
29 | if (machine->root_dir == NULL) | 31 | if (machine->root_dir == NULL) |
30 | return -ENOMEM; | 32 | return -ENOMEM; |
@@ -95,6 +97,7 @@ void machines__init(struct machines *machines) | |||
95 | { | 97 | { |
96 | machine__init(&machines->host, "", HOST_KERNEL_ID); | 98 | machine__init(&machines->host, "", HOST_KERNEL_ID); |
97 | machines->guests = RB_ROOT; | 99 | machines->guests = RB_ROOT; |
100 | machines->symbol_filter = NULL; | ||
98 | } | 101 | } |
99 | 102 | ||
100 | void machines__exit(struct machines *machines) | 103 | void machines__exit(struct machines *machines) |
@@ -118,6 +121,8 @@ struct machine *machines__add(struct machines *machines, pid_t pid, | |||
118 | return NULL; | 121 | return NULL; |
119 | } | 122 | } |
120 | 123 | ||
124 | machine->symbol_filter = machines->symbol_filter; | ||
125 | |||
121 | while (*p != NULL) { | 126 | while (*p != NULL) { |
122 | parent = *p; | 127 | parent = *p; |
123 | pos = rb_entry(parent, struct machine, rb_node); | 128 | pos = rb_entry(parent, struct machine, rb_node); |
@@ -133,6 +138,21 @@ struct machine *machines__add(struct machines *machines, pid_t pid, | |||
133 | return machine; | 138 | return machine; |
134 | } | 139 | } |
135 | 140 | ||
141 | void machines__set_symbol_filter(struct machines *machines, | ||
142 | symbol_filter_t symbol_filter) | ||
143 | { | ||
144 | struct rb_node *nd; | ||
145 | |||
146 | machines->symbol_filter = symbol_filter; | ||
147 | machines->host.symbol_filter = symbol_filter; | ||
148 | |||
149 | for (nd = rb_first(&machines->guests); nd; nd = rb_next(nd)) { | ||
150 | struct machine *machine = rb_entry(nd, struct machine, rb_node); | ||
151 | |||
152 | machine->symbol_filter = symbol_filter; | ||
153 | } | ||
154 | } | ||
155 | |||
136 | struct machine *machines__find(struct machines *machines, pid_t pid) | 156 | struct machine *machines__find(struct machines *machines, pid_t pid) |
137 | { | 157 | { |
138 | struct rb_node **p = &machines->guests.rb_node; | 158 | struct rb_node **p = &machines->guests.rb_node; |
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 5bb6244194d5..603ffba999d9 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h | |||
@@ -29,6 +29,7 @@ struct machine { | |||
29 | struct list_head kernel_dsos; | 29 | struct list_head kernel_dsos; |
30 | struct map_groups kmaps; | 30 | struct map_groups kmaps; |
31 | struct map *vmlinux_maps[MAP__NR_TYPES]; | 31 | struct map *vmlinux_maps[MAP__NR_TYPES]; |
32 | symbol_filter_t symbol_filter; | ||
32 | }; | 33 | }; |
33 | 34 | ||
34 | static inline | 35 | static inline |
@@ -51,6 +52,7 @@ typedef void (*machine__process_t)(struct machine *machine, void *data); | |||
51 | struct machines { | 52 | struct machines { |
52 | struct machine host; | 53 | struct machine host; |
53 | struct rb_root guests; | 54 | struct rb_root guests; |
55 | symbol_filter_t symbol_filter; | ||
54 | }; | 56 | }; |
55 | 57 | ||
56 | void machines__init(struct machines *machines); | 58 | void machines__init(struct machines *machines); |
@@ -68,6 +70,9 @@ struct machine *machines__findnew(struct machines *machines, pid_t pid); | |||
68 | void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size); | 70 | void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size); |
69 | char *machine__mmap_name(struct machine *machine, char *bf, size_t size); | 71 | char *machine__mmap_name(struct machine *machine, char *bf, size_t size); |
70 | 72 | ||
73 | void machines__set_symbol_filter(struct machines *machines, | ||
74 | symbol_filter_t symbol_filter); | ||
75 | |||
71 | int machine__init(struct machine *machine, const char *root_dir, pid_t pid); | 76 | int machine__init(struct machine *machine, const char *root_dir, pid_t pid); |
72 | void machine__exit(struct machine *machine); | 77 | void machine__exit(struct machine *machine); |
73 | void machine__delete_dead_threads(struct machine *machine); | 78 | void machine__delete_dead_threads(struct machine *machine); |