perf machine: Use machine__kernel_map() thoroughly
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 77e65977495cd6f6fcfacd8c16bdd9c8c18a1d72 Gitweb: http://git.kernel.org/tip/77e65977495cd6f6fcfacd8c16bdd9c8c18a1d72 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 30 Sep 2015 11:08:58 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 30 Sep 2015 18:34:28 -0300
perf machine: Use machine__kernel_map() thoroughly
In places where we were using its open coded equivalent.
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/tests/code-reading.c | 2 +- tools/perf/util/event.c | 7 +++---- tools/perf/util/machine.c | 23 ++++++++++++----------- tools/perf/util/map.c | 2 +- tools/perf/util/probe-event.c | 7 ++++--- 7 files changed, 23 insertions(+), 22 deletions(-)
tools/perf/builtin-kmem.c +1 -1
@@ -329,7 +329,7 @@ static int build_alloc_func_list(void)return -EINVAL ; } - kernel_map = machine->vmlinux_maps[MAP__FUNCTION ]; + kernel_map = machine__kernel_map(machine, MAP__FUNCTION)if (map__load (kernel_map,NULL ) <0 ) {pr_err ("cannot load kernel map\n" );return -ENOENT ;
tools/perf/builtin-report.c +1 -1
@@ -387,7 +387,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,static void report__warn_kptr_restrict (const struct report *rep) { -struct map *kernel_map = rep->session->machines.host.vmlinux_maps[MAP__FUNCTION ]; +struct map *kernel_map =machine__kernel_map (&rep->session->machines.host,MAP__FUNCTION );struct kmap *kernel_kmap = kernel_map ?map__kmap (kernel_map) :NULL ; if (kernel_map == NULL ||
tools/perf/tests/code-reading.c +1 -1
@@ -473,7 +473,7 @@ static int do_test_code_reading(bool try_kcore) symbol_conf.kallsyms_name ="/proc/kallsyms" ;/* Load kernel map */ - map = machine->vmlinux_maps[MAP__FUNCTION ]; + map =machine__kernel_map (machine,MAP__FUNCTION ); ret =map__load (map,NULL );if (ret <0 ) {pr_debug ("map__load failed\n" );
tools/perf/util/event.c +3 -4
@@ -649,12 +649,12 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,size_t size;const char *mmap_name;char name_buff[PATH_MAX ]; -struct map *map; +struct map *map =machine__kernel_map (machine,MAP__FUNCTION );struct kmap *kmap;int err;union perf_event *event; -if (machine->vmlinux_maps[0 ] ==NULL ) +if (map ==NULL )return -1 ;/*
@@ -680,7 +680,6 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, event->header.misc =PERF_RECORD_MISC_GUEST_KERNEL ; } - map = machine->vmlinux_maps[MAP__FUNCTION ]; kmap =map__kmap (map); size =snprintf (event->mmap.filename,sizeof (event->mmap.filename),"%s%s" , mmap_name, kmap->ref_reloc_sym->name) +1 ;
@@ -1008,7 +1007,7 @@ int perf_event__preprocess_sample(const union perf_event *event,* it now. */ if (cpumode ==PERF_RECORD_MISC_KERNEL && - machine->vmlinux_maps[MAP__FUNCTION ] ==NULL ) +machine__kernel_map (machine,MAP__FUNCTION ) ==NULL )machine__create_kernel_maps (machine);thread__find_addr_map (thread, cpumode,MAP__FUNCTION , sample->ip, al);
tools/perf/util/machine.c +12 -11
@@ -625,7 +625,7 @@ size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp) {int i;size_t printed =0 ; -struct dso *kdso = machine->vmlinux_maps[MAP__FUNCTION ]->dso; +struct dso *kdso =machine__kernel_map (machine,MAP__FUNCTION )->dso;if (kdso->has_build_id) {char filename[PATH_MAX ];
@@ -741,6 +741,7 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)for (type =0 ; type <MAP__NR_TYPES ; ++type) {struct kmap *kmap; +struct map *map; machine->vmlinux_maps[type] =map__new2 (start, kernel, type);if (machine->vmlinux_maps[type] ==NULL )
@@ -749,13 +750,13 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) machine->vmlinux_maps[type]->map_ip = machine->vmlinux_maps[type]->unmap_ip = identity__map_ip; - kmap =map__kmap (machine->vmlinux_maps[type]); + map =machine__kernel_map (machine, type); + kmap =map__kmap (map);if (!kmap)return -1 ; kmap->kmaps = &machine->kmaps; -map_groups__insert (&machine->kmaps, - machine->vmlinux_maps[type]); +map_groups__insert (&machine->kmaps, map); }return 0 ;
@@ -767,13 +768,13 @@ void machine__destroy_kernel_maps(struct machine *machine)for (type =0 ; type <MAP__NR_TYPES ; ++type) {struct kmap *kmap; +struct map *map =machine__kernel_map (machine, type); -if (machine->vmlinux_maps[type] ==NULL ) +if (map ==NULL )continue ; - kmap =map__kmap (machine->vmlinux_maps[type]); -map_groups__remove (&machine->kmaps, - machine->vmlinux_maps[type]); + kmap =map__kmap (map); +map_groups__remove (&machine->kmaps, map);if (kmap && kmap->ref_reloc_sym) {/* * ref_reloc_sym is shared among all maps, so free just
@@ -867,7 +868,7 @@ int machines__create_kernel_maps(struct machines *machines, pid_t pid)int machine__load_kallsyms (struct machine *machine,const char *filename,enum map_type type,symbol_filter_t filter) { -struct map *map = machine->vmlinux_maps[type]; +struct map *map =machine__kernel_map (machine,MAP__FUNCTION );int ret =dso__load_kallsyms (map->dso, filename, map, filter);if (ret >0 ) {
@@ -886,7 +887,7 @@ int machine__load_kallsyms(struct machine *machine, const char *filename,int machine__load_vmlinux_path (struct machine *machine,enum map_type type,symbol_filter_t filter) { -struct map *map = machine->vmlinux_maps[type]; +struct map *map =machine__kernel_map (machine,MAP__FUNCTION );int ret =dso__load_vmlinux_path (map->dso, map, filter);if (ret >0 )
@@ -1244,7 +1245,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,/* * preload dso of guest kernel and modules */ -dso__load (kernel, machine->vmlinux_maps[MAP__FUNCTION ], +dso__load (kernel,machine__kernel_map (machine,MAP__FUNCTION ),NULL ); } }
tools/perf/util/map.c +1 -1
@@ -235,7 +235,7 @@ struct map *map__new2(u64 start, struct dso *dso, enum map_type type)*/ bool __map__is_kernel (const struct map *map) { -return map->groups->machine->vmlinux_maps[map->type] == map; +return machine__kernel_map (map->groups->machine, map->type) == map; }static void map__exit (struct map *map)
tools/perf/util/probe-event.c +4 -3
@@ -126,11 +126,12 @@ static struct ref_reloc_sym *kernel_get_ref_reloc_sym(void) {/* kmap->ref_reloc_sym should be set if host_machine is initialized */ struct kmap *kmap; +struct map *map =machine__kernel_map (host_machine,MAP__FUNCTION ); -if (map__load (host_machine->vmlinux_maps[MAP__FUNCTION ],NULL ) <0 ) +if (map__load (map,NULL ) <0 )return NULL ; - kmap =map__kmap (host_machine->vmlinux_maps[MAP__FUNCTION ]); + kmap =map__kmap (map);if (!kmap)return NULL ;return kmap->ref_reloc_sym;
@@ -281,7 +282,7 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso)return -ENOENT ; } - map = host_machine->vmlinux_maps[MAP__FUNCTION ]; + map =machine__kernel_map (host_machine,MAP__FUNCTION ); dso = map->dso; vmlinux_name = symbol_conf.vmlinux_name;