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

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

+5 -4
+5 -4
tools/perf/util/machine.c
··· 1135 1135 { 1136 1136 struct dso *kernel = machine__get_kernel(machine); 1137 1137 const char *name; 1138 - u64 addr = machine__get_running_kernel_start(machine, &name); 1138 + u64 addr; 1139 1139 int ret; 1140 1140 1141 - if (!addr || kernel == NULL) 1141 + if (kernel == NULL) 1142 1142 return -1; 1143 1143 1144 1144 ret = __machine__create_kernel_maps(machine, kernel); ··· 1160 1160 */ 1161 1161 map_groups__fixup_end(&machine->kmaps); 1162 1162 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)) { 1165 1166 machine__destroy_kernel_maps(machine); 1166 1167 return -1; 1167 1168 }