aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-05-22 10:52:22 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-05-27 11:21:45 -0400
commit4bb7123dcfa7aa1d963ad4a8f01b88d54a2bb873 (patch)
treec75934a5be0224534f73ae014f3f4bb29b866f3c
parent614c6b570d5157c2cf835d334bc89af071fc2e44 (diff)
perf tools: Use maps__first()/map__next()
In a few more remaining places, for consistency. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-c2n7slwtto29wndfttdrhfrx@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/tests/vmlinux-kallsyms.c34
-rw-r--r--tools/perf/util/event.c7
-rw-r--r--tools/perf/util/map.c7
-rw-r--r--tools/perf/util/probe-event.c6
-rw-r--r--tools/perf/util/symbol.c23
5 files changed, 37 insertions, 40 deletions
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 3d9088003a5b..94ac6924df65 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -23,9 +23,10 @@ int test__vmlinux_matches_kallsyms(void)
23 int err = -1; 23 int err = -1;
24 struct rb_node *nd; 24 struct rb_node *nd;
25 struct symbol *sym; 25 struct symbol *sym;
26 struct map *kallsyms_map, *vmlinux_map; 26 struct map *kallsyms_map, *vmlinux_map, *map;
27 struct machine kallsyms, vmlinux; 27 struct machine kallsyms, vmlinux;
28 enum map_type type = MAP__FUNCTION; 28 enum map_type type = MAP__FUNCTION;
29 struct rb_root *maps = &vmlinux.kmaps.maps[type];
29 u64 mem_start, mem_end; 30 u64 mem_start, mem_end;
30 31
31 /* 32 /*
@@ -184,8 +185,8 @@ detour:
184 185
185 pr_info("Maps only in vmlinux:\n"); 186 pr_info("Maps only in vmlinux:\n");
186 187
187 for (nd = rb_first(&vmlinux.kmaps.maps[type]); nd; nd = rb_next(nd)) { 188 for (map = maps__first(maps); map; map = map__next(map)) {
188 struct map *pos = rb_entry(nd, struct map, rb_node), *pair; 189 struct map *
189 /* 190 /*
190 * If it is the kernel, kallsyms is always "[kernel.kallsyms]", while 191 * If it is the kernel, kallsyms is always "[kernel.kallsyms]", while
191 * the kernel will have the path for the vmlinux file being used, 192 * the kernel will have the path for the vmlinux file being used,
@@ -193,22 +194,22 @@ detour:
193 * both cases. 194 * both cases.
194 */ 195 */
195 pair = map_groups__find_by_name(&kallsyms.kmaps, type, 196 pair = map_groups__find_by_name(&kallsyms.kmaps, type,
196 (pos->dso->kernel ? 197 (map->dso->kernel ?
197 pos->dso->short_name : 198 map->dso->short_name :
198 pos->dso->name)); 199 map->dso->name));
199 if (pair) 200 if (pair)
200 pair->priv = 1; 201 pair->priv = 1;
201 else 202 else
202 map__fprintf(pos, stderr); 203 map__fprintf(map, stderr);
203 } 204 }
204 205
205 pr_info("Maps in vmlinux with a different name in kallsyms:\n"); 206 pr_info("Maps in vmlinux with a different name in kallsyms:\n");
206 207
207 for (nd = rb_first(&vmlinux.kmaps.maps[type]); nd; nd = rb_next(nd)) { 208 for (map = maps__first(maps); map; map = map__next(map)) {
208 struct map *pos = rb_entry(nd, struct map, rb_node), *pair; 209 struct map *pair;
209 210
210 mem_start = vmlinux_map->unmap_ip(vmlinux_map, pos->start); 211 mem_start = vmlinux_map->unmap_ip(vmlinux_map, map->start);
211 mem_end = vmlinux_map->unmap_ip(vmlinux_map, pos->end); 212 mem_end = vmlinux_map->unmap_ip(vmlinux_map, map->end);
212 213
213 pair = map_groups__find(&kallsyms.kmaps, type, mem_start); 214 pair = map_groups__find(&kallsyms.kmaps, type, mem_start);
214 if (pair == NULL || pair->priv) 215 if (pair == NULL || pair->priv)
@@ -217,7 +218,7 @@ detour:
217 if (pair->start == mem_start) { 218 if (pair->start == mem_start) {
218 pair->priv = 1; 219 pair->priv = 1;
219 pr_info(" %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as", 220 pr_info(" %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as",
220 pos->start, pos->end, pos->pgoff, pos->dso->name); 221 map->start, map->end, map->pgoff, map->dso->name);
221 if (mem_end != pair->end) 222 if (mem_end != pair->end)
222 pr_info(":\n*%" PRIx64 "-%" PRIx64 " %" PRIx64, 223 pr_info(":\n*%" PRIx64 "-%" PRIx64 " %" PRIx64,
223 pair->start, pair->end, pair->pgoff); 224 pair->start, pair->end, pair->pgoff);
@@ -228,12 +229,11 @@ detour:
228 229
229 pr_info("Maps only in kallsyms:\n"); 230 pr_info("Maps only in kallsyms:\n");
230 231
231 for (nd = rb_first(&kallsyms.kmaps.maps[type]); 232 maps = &kallsyms.kmaps.maps[type];
232 nd; nd = rb_next(nd)) {
233 struct map *pos = rb_entry(nd, struct map, rb_node);
234 233
235 if (!pos->priv) 234 for (map = maps__first(maps); map; map = map__next(map)) {
236 map__fprintf(pos, stderr); 235 if (!map->priv)
236 map__fprintf(map, stderr);
237 } 237 }
238out: 238out:
239 machine__exit(&kallsyms); 239 machine__exit(&kallsyms);
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index a513a51f7330..9d3bba175423 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -329,8 +329,9 @@ int perf_event__synthesize_modules(struct perf_tool *tool,
329 struct machine *machine) 329 struct machine *machine)
330{ 330{
331 int rc = 0; 331 int rc = 0;
332 struct rb_node *nd; 332 struct map *pos;
333 struct map_groups *kmaps = &machine->kmaps; 333 struct map_groups *kmaps = &machine->kmaps;
334 struct rb_root *maps = &kmaps->maps[MAP__FUNCTION];
334 union perf_event *event = zalloc((sizeof(event->mmap) + 335 union perf_event *event = zalloc((sizeof(event->mmap) +
335 machine->id_hdr_size)); 336 machine->id_hdr_size));
336 if (event == NULL) { 337 if (event == NULL) {
@@ -350,10 +351,8 @@ int perf_event__synthesize_modules(struct perf_tool *tool,
350 else 351 else
351 event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL; 352 event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL;
352 353
353 for (nd = rb_first(&kmaps->maps[MAP__FUNCTION]); 354 for (pos = maps__first(maps); pos; pos = map__next(pos)) {
354 nd; nd = rb_next(nd)) {
355 size_t size; 355 size_t size;
356 struct map *pos = rb_entry(nd, struct map, rb_node);
357 356
358 if (pos->dso->kernel) 357 if (pos->dso->kernel)
359 continue; 358 continue;
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index c1bfd0a12a94..898ab92a98dd 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -688,9 +688,10 @@ move_map:
688int map_groups__clone(struct map_groups *mg, 688int map_groups__clone(struct map_groups *mg,
689 struct map_groups *parent, enum map_type type) 689 struct map_groups *parent, enum map_type type)
690{ 690{
691 struct rb_node *nd; 691 struct map *map;
692 for (nd = rb_first(&parent->maps[type]); nd; nd = rb_next(nd)) { 692 struct rb_root *maps = &parent->maps[type];
693 struct map *map = rb_entry(nd, struct map, rb_node); 693
694 for (map = maps__first(maps); map; map = map__next(map)) {
694 struct map *new = map__clone(map); 695 struct map *new = map__clone(map);
695 if (new == NULL) 696 if (new == NULL)
696 return -ENOMEM; 697 return -ENOMEM;
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index db6021834e8f..092256516262 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -162,8 +162,9 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
162 162
163static struct map *kernel_get_module_map(const char *module) 163static struct map *kernel_get_module_map(const char *module)
164{ 164{
165 struct rb_node *nd;
166 struct map_groups *grp = &host_machine->kmaps; 165 struct map_groups *grp = &host_machine->kmaps;
166 struct rb_root *maps = &grp->maps[MAP__FUNCTION];
167 struct map *pos;
167 168
168 /* A file path -- this is an offline module */ 169 /* A file path -- this is an offline module */
169 if (module && strchr(module, '/')) 170 if (module && strchr(module, '/'))
@@ -172,8 +173,7 @@ static struct map *kernel_get_module_map(const char *module)
172 if (!module) 173 if (!module)
173 module = "kernel"; 174 module = "kernel";
174 175
175 for (nd = rb_first(&grp->maps[MAP__FUNCTION]); nd; nd = rb_next(nd)) { 176 for (pos = maps__first(maps); pos; pos = map__next(pos)) {
176 struct map *pos = rb_entry(nd, struct map, rb_node);
177 if (strncmp(pos->dso->short_name + 1, module, 177 if (strncmp(pos->dso->short_name + 1, module,
178 pos->dso->short_name_len - 2) == 0) { 178 pos->dso->short_name_len - 2) == 0) {
179 return pos; 179 return pos;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 82a31fd0fcf5..00b6b17e74a7 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -202,18 +202,16 @@ void symbols__fixup_end(struct rb_root *symbols)
202 202
203void __map_groups__fixup_end(struct map_groups *mg, enum map_type type) 203void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
204{ 204{
205 struct map *prev, *curr; 205 struct rb_root *maps = &mg->maps[type];
206 struct rb_node *nd, *prevnd = rb_first(&mg->maps[type]); 206 struct map *next, *curr;
207 207
208 if (prevnd == NULL) 208 curr = maps__first(maps);
209 if (curr == NULL)
209 return; 210 return;
210 211
211 curr = rb_entry(prevnd, struct map, rb_node); 212 for (next = map__next(curr); next; next = map__next(curr)) {
212 213 curr->end = next->start;
213 for (nd = rb_next(prevnd); nd; nd = rb_next(nd)) { 214 curr = next;
214 prev = curr;
215 curr = rb_entry(nd, struct map, rb_node);
216 prev->end = curr->start;
217 } 215 }
218 216
219 /* 217 /*
@@ -1522,11 +1520,10 @@ out:
1522struct map *map_groups__find_by_name(struct map_groups *mg, 1520struct map *map_groups__find_by_name(struct map_groups *mg,
1523 enum map_type type, const char *name) 1521 enum map_type type, const char *name)
1524{ 1522{
1525 struct rb_node *nd; 1523 struct rb_root *maps = &mg->maps[type];
1526 1524 struct map *map;
1527 for (nd = rb_first(&mg->maps[type]); nd; nd = rb_next(nd)) {
1528 struct map *map = rb_entry(nd, struct map, rb_node);
1529 1525
1526 for (map = maps__first(maps); map; map = map__next(map)) {
1530 if (map->dso && strcmp(map->dso->short_name, name) == 0) 1527 if (map->dso && strcmp(map->dso->short_name, name) == 0)
1531 return map; 1528 return map;
1532 } 1529 }