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 probe: Provide more detail with relocation warning

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>

authored by

Ravi Bangoria and committed by
Arnaldo Carvalho de Melo
41ca1d1e 6793672a

+8 -3
+8 -3
tools/perf/util/probe-event.c
··· 108 108 109 109 static struct ref_reloc_sym *kernel_get_ref_reloc_sym(struct map **pmap) 110 110 { 111 - /* kmap->ref_reloc_sym should be set if host_machine is initialized */ 112 111 struct kmap *kmap; 113 112 struct map *map = machine__kernel_map(host_machine); 114 113 ··· 818 819 819 820 reloc_sym = kernel_get_ref_reloc_sym(&map); 820 821 if (!reloc_sym) { 821 - pr_warning("Relocated base symbol is not found!\n"); 822 + pr_warning("Relocated base symbol is not found! " 823 + "Check /proc/sys/kernel/kptr_restrict\n" 824 + "and /proc/sys/kernel/perf_event_paranoid. " 825 + "Or run as privileged perf user.\n\n"); 822 826 return -EINVAL; 823 827 } 824 828 ··· 3027 3025 (!pp->retprobe || kretprobe_offset_is_supported())) { 3028 3026 reloc_sym = kernel_get_ref_reloc_sym(NULL); 3029 3027 if (!reloc_sym) { 3030 - pr_warning("Relocated base symbol is not found!\n"); 3028 + pr_warning("Relocated base symbol is not found! " 3029 + "Check /proc/sys/kernel/kptr_restrict\n" 3030 + "and /proc/sys/kernel/perf_event_paranoid. " 3031 + "Or run as privileged perf user.\n\n"); 3031 3032 ret = -EINVAL; 3032 3033 goto out; 3033 3034 }