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

Configure Feed

Select the types of activity you want to include in your feed.

perf machine: Read also the end of the kernel

We mark the end of kernel based on the first module, but that could
cover some bpf program maps. Reading _etext symbol if it's present to
get precise kernel map end.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stanislav Fomichev <sdf@google.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Link: http://lkml.kernel.org/r/20190508132010.14512-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
ed9adb20 93f678b9

+18 -9
+18 -9
tools/perf/util/machine.c
··· 924 924 * symbol_name if it's not that important. 925 925 */ 926 926 static int machine__get_running_kernel_start(struct machine *machine, 927 - const char **symbol_name, u64 *start) 927 + const char **symbol_name, 928 + u64 *start, u64 *end) 928 929 { 929 930 char filename[PATH_MAX]; 930 931 int i, err = -1; ··· 950 949 *symbol_name = name; 951 950 952 951 *start = addr; 952 + 953 + err = kallsyms__get_function_start(filename, "_etext", &addr); 954 + if (!err) 955 + *end = addr; 956 + 953 957 return 0; 954 958 } 955 959 ··· 1447 1441 struct dso *kernel = machine__get_kernel(machine); 1448 1442 const char *name = NULL; 1449 1443 struct map *map; 1450 - u64 addr = 0; 1444 + u64 start = 0, end = ~0ULL; 1451 1445 int ret; 1452 1446 1453 1447 if (kernel == NULL) ··· 1466 1460 "continuing anyway...\n", machine->pid); 1467 1461 } 1468 1462 1469 - if (!machine__get_running_kernel_start(machine, &name, &addr)) { 1463 + if (!machine__get_running_kernel_start(machine, &name, &start, &end)) { 1470 1464 if (name && 1471 - map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, addr)) { 1465 + map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, start)) { 1472 1466 machine__destroy_kernel_maps(machine); 1473 1467 ret = -1; 1474 1468 goto out_put; ··· 1478 1472 * we have a real start address now, so re-order the kmaps 1479 1473 * assume it's the last in the kmaps 1480 1474 */ 1481 - machine__update_kernel_mmap(machine, addr, ~0ULL); 1475 + machine__update_kernel_mmap(machine, start, end); 1482 1476 } 1483 1477 1484 1478 if (machine__create_extra_kernel_maps(machine, kernel)) 1485 1479 pr_debug("Problems creating extra kernel maps, continuing anyway...\n"); 1486 1480 1487 - /* update end address of the kernel map using adjacent module address */ 1488 - map = map__next(machine__kernel_map(machine)); 1489 - if (map) 1490 - machine__set_kernel_mmap(machine, addr, map->start); 1481 + if (end == ~0ULL) { 1482 + /* update end address of the kernel map using adjacent module address */ 1483 + map = map__next(machine__kernel_map(machine)); 1484 + if (map) 1485 + machine__set_kernel_mmap(machine, start, map->start); 1486 + } 1487 + 1491 1488 out_put: 1492 1489 dso__put(kernel); 1493 1490 return ret;