Skip to content

Commit 45e9005

Browse files
committed
perf machine: Do not bail out if not managing to read ref reloc symbol
This means the user can't access /proc/kallsyms, for instance, because /proc/sys/kernel/kptr_restrict is set to 1. Instead leave the ref_reloc_sym as NULL and code using it will cope. This allows 'perf trace' to work on such systems for !root, the only issue would be when trying to resolve kernel symbols, which happens, for instance, in some libtracevent plugins. A warning for that case will be provided in the next patch in this series. Noticed in Ubuntu 16.04, that comes with kptr_restrict=1. Reported-by: Milian Wolff <[email protected]> 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]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a29d5c9 commit 45e9005

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tools/perf/util/machine.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,10 +1135,10 @@ int machine__create_kernel_maps(struct machine *machine)
11351135
{
11361136
struct dso *kernel = machine__get_kernel(machine);
11371137
const char *name;
1138-
u64 addr = machine__get_running_kernel_start(machine, &name);
1138+
u64 addr;
11391139
int ret;
11401140

1141-
if (!addr || kernel == NULL)
1141+
if (kernel == NULL)
11421142
return -1;
11431143

11441144
ret = __machine__create_kernel_maps(machine, kernel);
@@ -1160,8 +1160,9 @@ int machine__create_kernel_maps(struct machine *machine)
11601160
*/
11611161
map_groups__fixup_end(&machine->kmaps);
11621162

1163-
if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name,
1164-
addr)) {
1163+
addr = machine__get_running_kernel_start(machine, &name);
1164+
if (!addr) {
1165+
} else if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) {
11651166
machine__destroy_kernel_maps(machine);
11661167
return -1;
11671168
}

0 commit comments

Comments
 (0)