Skip to content

Commit

Permalink
perf probe: Provide more detail with relocation warning
Browse files Browse the repository at this point in the history
When run as normal user with default sysctl kernel.kptr_restrict=0
and kernel.perf_event_paranoid=2, perf probe fails with:

  $ ./perf probe move_page_tables
  Relocated base symbol is not found!

The warning message is not much informative. The reason perf fails
is because /proc/kallsyms is restricted by perf_event_paranoid=2
for normal user and thus perf fails to read relocated address of
the base symbol.

Tweaking kptr_restrict and perf_event_paranoid can change the
behavior of perf probe. Also, running as root or privileged user
works too. Add these details in the warning message.

Plus, kmap->ref_reloc_sym might not be always set even if
host_machine is initialized. Above is the example of the same.
Remove that comment.

Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lore.kernel.org/lkml/20210525043744.193297-1-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Ravi Bangoria authored and Arnaldo Carvalho de Melo committed May 27, 2021
1 parent 6793672 commit 41ca1d1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ void exit_probe_symbol_maps(void)

static struct ref_reloc_sym *kernel_get_ref_reloc_sym(struct map **pmap)
{
/* kmap->ref_reloc_sym should be set if host_machine is initialized */
struct kmap *kmap;
struct map *map = machine__kernel_map(host_machine);

Expand Down Expand Up @@ -819,7 +818,10 @@ post_process_kernel_probe_trace_events(struct probe_trace_event *tevs,

reloc_sym = kernel_get_ref_reloc_sym(&map);
if (!reloc_sym) {
pr_warning("Relocated base symbol is not found!\n");
pr_warning("Relocated base symbol is not found! "
"Check /proc/sys/kernel/kptr_restrict\n"
"and /proc/sys/kernel/perf_event_paranoid. "
"Or run as privileged perf user.\n\n");
return -EINVAL;
}

Expand Down Expand Up @@ -3025,7 +3027,10 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
(!pp->retprobe || kretprobe_offset_is_supported())) {
reloc_sym = kernel_get_ref_reloc_sym(NULL);
if (!reloc_sym) {
pr_warning("Relocated base symbol is not found!\n");
pr_warning("Relocated base symbol is not found! "
"Check /proc/sys/kernel/kptr_restrict\n"
"and /proc/sys/kernel/perf_event_paranoid. "
"Or run as privileged perf user.\n\n");
ret = -EINVAL;
goto out;
}
Expand Down

0 comments on commit 41ca1d1

Please sign in to comment.