[PATCH 1/1] perf record: Handle restrictive permissions in /proc/{kallsyms,modules}

From: Arnaldo Carvalho de Melo
Date: Mon Nov 22 2010 - 11:34:14 EST


From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

The 59365d1 commit, even being reverted by 33e0d57, showed a non robust
behavior in 'perf record': it really should just warn the user that some
functionality will not be available.

The new behavior then becomes:

[acme@felicio linux]$ ls -la /proc/{kallsyms,modules}
-r-------- 1 root root 0 Nov 22 12:19 /proc/kallsyms
-r-------- 1 root root 0 Nov 22 12:19 /proc/modules
[acme@felicio linux]$ perf record ls -R > /dev/null
Couldn't record kernel reference relocation symbol
Symbol resolution may be skewed if relocation was used (e.g. kexec).
Check /proc/kallsyms permission or run as root.
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.004 MB perf.data (~161 samples) ]
[acme@felicio linux]$ perf report --stdio
[kernel.kallsyms] with build id 77b05e00e64e4de1c9347d83879779b540d69f00 not found, continuing without symbols
# Events: 98 cycles
#
# Overhead Command Shared Object Symbol
# ........ ....... ............... ....................
#
48.26% ls [kernel] [k] ffffffff8102b92b
22.49% ls libc-2.12.90.so [.] __strlen_sse2
8.35% ls libc-2.12.90.so [.] __GI___strcoll_l
8.17% ls ls [.] 11580
3.35% ls libc-2.12.90.so [.] _IO_new_file_xsputn
3.33% ls libc-2.12.90.so [.] _int_malloc
1.88% ls libc-2.12.90.so [.] _int_free
0.84% ls libc-2.12.90.so [.] malloc_consolidate
0.84% ls libc-2.12.90.so [.] __readdir64
0.83% ls ls [.] strlen@plt
0.83% ls libc-2.12.90.so [.] __GI_fwrite_unlocked
0.83% ls libc-2.12.90.so [.] __memcpy_sse2

#
# (For a higher level overview, try: perf report --sort comm,dso)
#
[acme@felicio linux]$

It still has the build-ids for DSOs in the maps with hits:

[acme@felicio linux]$ perf buildid-list
77b05e00e64e4de1c9347d83879779b540d69f00 [kernel.kallsyms]
09c4a431a4a8b648fcfc2c2bdda70f56050ddff1 /bin/ls
af75ea9ad951d25e0f038901a11b3846dccb29a4 /lib64/libc-2.12.90.so
[acme@felicio linux]$

That can be used in another machine to resolve kernel symbols.

Cc: Eugene Teo <eugeneteo@xxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Jesper Juhl <jj@xxxxxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Marcus Meissner <meissner@xxxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Sarah Sharp <sarah.a.sharp@xxxxxxxxxxxxxxx>
Cc: Stephane Eranian <eranian@xxxxxxxxxx>
Cc: Tejun Heo <tj@xxxxxxxxxx>
Cc: Tom Zanussi <tzanussi@xxxxxxxxx>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/builtin-record.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 93bd2ff..e2c2de2 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -697,17 +697,18 @@ static int __cmd_record(int argc, const char **argv)
if (err < 0)
err = event__synthesize_kernel_mmap(process_synthesized_event,
session, machine, "_stext");
- if (err < 0) {
- pr_err("Couldn't record kernel reference relocation symbol.\n");
- return err;
- }
+ if (err < 0)
+ pr_err("Couldn't record kernel reference relocation symbol\n"
+ "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
+ "Check /proc/kallsyms permission or run as root.\n");

err = event__synthesize_modules(process_synthesized_event,
session, machine);
- if (err < 0) {
- pr_err("Couldn't record kernel reference relocation symbol.\n");
- return err;
- }
+ if (err < 0)
+ pr_err("Couldn't record kernel module information.\n"
+ "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
+ "Check /proc/modules permission or run as root.\n");
+
if (perf_guest)
perf_session__process_machines(session, event__synthesize_guest_os);

--
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/