Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf machine: Add method for common kernel_map(FUNCTION) operation

And it is also a step in the direction of killing the separation of data
and text maps in map_groups.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-rrds86kb3wx5wk8v38v56gw8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+25 -20
+1 -1
tools/perf/builtin-kmem.c
··· 329 329 return -EINVAL; 330 330 } 331 331 332 - kernel_map = machine__kernel_map(machine, MAP__FUNCTION) 332 + kernel_map = machine__kernel_map(machine); 333 333 if (map__load(kernel_map, NULL) < 0) { 334 334 pr_err("cannot load kernel map\n"); 335 335 return -ENOENT;
+1 -1
tools/perf/builtin-report.c
··· 387 387 388 388 static void report__warn_kptr_restrict(const struct report *rep) 389 389 { 390 - struct map *kernel_map = machine__kernel_map(&rep->session->machines.host, MAP__FUNCTION); 390 + struct map *kernel_map = machine__kernel_map(&rep->session->machines.host); 391 391 struct kmap *kernel_kmap = kernel_map ? map__kmap(kernel_map) : NULL; 392 392 393 393 if (kernel_map == NULL ||
+1 -1
tools/perf/tests/code-reading.c
··· 473 473 symbol_conf.kallsyms_name = "/proc/kallsyms"; 474 474 475 475 /* Load kernel map */ 476 - map = machine__kernel_map(machine, MAP__FUNCTION); 476 + map = machine__kernel_map(machine); 477 477 ret = map__load(map, NULL); 478 478 if (ret < 0) { 479 479 pr_debug("map__load failed\n");
+2 -2
tools/perf/tests/vmlinux-kallsyms.c
··· 68 68 * to see if the running kernel was relocated by checking if it has the 69 69 * same value in the vmlinux file we load. 70 70 */ 71 - kallsyms_map = machine__kernel_map(&kallsyms, type); 71 + kallsyms_map = machine__kernel_map(&kallsyms); 72 72 73 73 /* 74 74 * Step 5: ··· 80 80 goto out; 81 81 } 82 82 83 - vmlinux_map = machine__kernel_map(&vmlinux, type); 83 + vmlinux_map = machine__kernel_map(&vmlinux); 84 84 85 85 /* 86 86 * Step 6:
+2 -2
tools/perf/util/event.c
··· 649 649 size_t size; 650 650 const char *mmap_name; 651 651 char name_buff[PATH_MAX]; 652 - struct map *map = machine__kernel_map(machine, MAP__FUNCTION); 652 + struct map *map = machine__kernel_map(machine); 653 653 struct kmap *kmap; 654 654 int err; 655 655 union perf_event *event; ··· 1007 1007 * it now. 1008 1008 */ 1009 1009 if (cpumode == PERF_RECORD_MISC_KERNEL && 1010 - machine__kernel_map(machine, MAP__FUNCTION) == NULL) 1010 + machine__kernel_map(machine) == NULL) 1011 1011 machine__create_kernel_maps(machine); 1012 1012 1013 1013 thread__find_addr_map(thread, cpumode, MAP__FUNCTION, sample->ip, al);
+1 -1
tools/perf/util/intel-pt.c
··· 1268 1268 if (ptss_ip) 1269 1269 *ptss_ip = 0; 1270 1270 1271 - map = machine__kernel_map(machine, MAP__FUNCTION); 1271 + map = machine__kernel_map(machine); 1272 1272 if (!map) 1273 1273 return 0; 1274 1274
+7 -8
tools/perf/util/machine.c
··· 625 625 { 626 626 int i; 627 627 size_t printed = 0; 628 - struct dso *kdso = machine__kernel_map(machine, MAP__FUNCTION)->dso; 628 + struct dso *kdso = machine__kernel_map(machine)->dso; 629 629 630 630 if (kdso->has_build_id) { 631 631 char filename[PATH_MAX]; ··· 750 750 machine->vmlinux_maps[type]->map_ip = 751 751 machine->vmlinux_maps[type]->unmap_ip = 752 752 identity__map_ip; 753 - map = machine__kernel_map(machine, type); 753 + map = __machine__kernel_map(machine, type); 754 754 kmap = map__kmap(map); 755 755 if (!kmap) 756 756 return -1; ··· 768 768 769 769 for (type = 0; type < MAP__NR_TYPES; ++type) { 770 770 struct kmap *kmap; 771 - struct map *map = machine__kernel_map(machine, type); 771 + struct map *map = __machine__kernel_map(machine, type); 772 772 773 773 if (map == NULL) 774 774 continue; ··· 868 868 int machine__load_kallsyms(struct machine *machine, const char *filename, 869 869 enum map_type type, symbol_filter_t filter) 870 870 { 871 - struct map *map = machine__kernel_map(machine, MAP__FUNCTION); 871 + struct map *map = machine__kernel_map(machine); 872 872 int ret = dso__load_kallsyms(map->dso, filename, map, filter); 873 873 874 874 if (ret > 0) { ··· 887 887 int machine__load_vmlinux_path(struct machine *machine, enum map_type type, 888 888 symbol_filter_t filter) 889 889 { 890 - struct map *map = machine__kernel_map(machine, MAP__FUNCTION); 890 + struct map *map = machine__kernel_map(machine); 891 891 int ret = dso__load_vmlinux_path(map->dso, map, filter); 892 892 893 893 if (ret > 0) ··· 1245 1245 /* 1246 1246 * preload dso of guest kernel and modules 1247 1247 */ 1248 - dso__load(kernel, machine__kernel_map(machine, MAP__FUNCTION), 1249 - NULL); 1248 + dso__load(kernel, machine__kernel_map(machine), NULL); 1250 1249 } 1251 1250 } 1252 1251 return 0; ··· 1997 1998 1998 1999 int machine__get_kernel_start(struct machine *machine) 1999 2000 { 2000 - struct map *map = machine__kernel_map(machine, MAP__FUNCTION); 2001 + struct map *map = machine__kernel_map(machine); 2001 2002 int err = 0; 2002 2003 2003 2004 /*
+7 -1
tools/perf/util/machine.h
··· 48 48 }; 49 49 50 50 static inline 51 - struct map *machine__kernel_map(struct machine *machine, enum map_type type) 51 + struct map *__machine__kernel_map(struct machine *machine, enum map_type type) 52 52 { 53 53 return machine->vmlinux_maps[type]; 54 + } 55 + 56 + static inline 57 + struct map *machine__kernel_map(struct machine *machine) 58 + { 59 + return __machine__kernel_map(machine, MAP__FUNCTION); 54 60 } 55 61 56 62 int machine__get_kernel_start(struct machine *machine);
+1 -1
tools/perf/util/map.c
··· 235 235 */ 236 236 bool __map__is_kernel(const struct map *map) 237 237 { 238 - return machine__kernel_map(map->groups->machine, map->type) == map; 238 + return __machine__kernel_map(map->groups->machine, map->type) == map; 239 239 } 240 240 241 241 static void map__exit(struct map *map)
+2 -2
tools/perf/util/probe-event.c
··· 126 126 { 127 127 /* kmap->ref_reloc_sym should be set if host_machine is initialized */ 128 128 struct kmap *kmap; 129 - struct map *map = machine__kernel_map(host_machine, MAP__FUNCTION); 129 + struct map *map = machine__kernel_map(host_machine); 130 130 131 131 if (map__load(map, NULL) < 0) 132 132 return NULL; ··· 282 282 return -ENOENT; 283 283 } 284 284 285 - map = machine__kernel_map(host_machine, MAP__FUNCTION); 285 + map = machine__kernel_map(host_machine); 286 286 dso = map->dso; 287 287 288 288 vmlinux_name = symbol_conf.vmlinux_name;