Skip to content

Commit

Permalink
perf machine: Do not bail out if not managing to read ref reloc symbol
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed May 20, 2016
1 parent a29d5c9 commit 45e9005
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/perf/util/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,10 +1135,10 @@ int machine__create_kernel_maps(struct machine *machine)
{
struct dso *kernel = machine__get_kernel(machine);
const char *name;
u64 addr = machine__get_running_kernel_start(machine, &name);
u64 addr;
int ret;

if (!addr || kernel == NULL)
if (kernel == NULL)
return -1;

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

if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name,
addr)) {
addr = machine__get_running_kernel_start(machine, &name);
if (!addr) {
} else if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) {
machine__destroy_kernel_maps(machine);
return -1;
}
Expand Down

0 comments on commit 45e9005

Please sign in to comment.