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

perf trace: Improve the error messages

Currently, execution of 'perf trace' reports the following cryptic
message to the user:

$ perf trace
Couldn't read the raw_syscalls tracepoints information!

Typically this happens because the user does not have permissions to
read the debugfs filesystem. Also handle the case when the kernel was
not compiled with debugfs support or when it isn't mounted.

Now, the tool prints detailed error messages:

$ perf trace
Error: Unable to find debugfs
Hint: Was your kernel was compiled with debugfs support?
Hint: Is the debugfs filesystem mounted?
Hint: Try 'sudo mount -t debugfs nodev /sys/kernel/debug'

$ perf trace
Error: No permissions to read /sys/kernel/debug//tracing/events/raw_syscalls
Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/'

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1380863851-14460-1-git-send-email-artagnon@gmail.com
[ Added ready to use commands to fix the issues as extra hints, use the
current debugfs mount point when reporting permission error, use
strerror_r instead of the deprecated sys_errlist, as reported by David Ahern ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ramkumar Ramachandra and committed by
Arnaldo Carvalho de Melo
87f91868 d366c53e

+28 -9
+28 -9
tools/perf/builtin-trace.c
··· 1590 1590 } 1591 1591 1592 1592 if (perf_evlist__add_newtp(evlist, "raw_syscalls", "sys_enter", trace__sys_enter) || 1593 - perf_evlist__add_newtp(evlist, "raw_syscalls", "sys_exit", trace__sys_exit)) { 1594 - fprintf(trace->output, "Couldn't read the raw_syscalls tracepoints information!\n"); 1595 - goto out_delete_evlist; 1596 - } 1593 + perf_evlist__add_newtp(evlist, "raw_syscalls", "sys_exit", trace__sys_exit)) 1594 + goto out_error_tp; 1597 1595 1598 1596 if (trace->sched && 1599 - perf_evlist__add_newtp(evlist, "sched", "sched_stat_runtime", 1600 - trace__sched_stat_runtime)) { 1601 - fprintf(trace->output, "Couldn't read the sched_stat_runtime tracepoint information!\n"); 1602 - goto out_delete_evlist; 1603 - } 1597 + perf_evlist__add_newtp(evlist, "sched", "sched_stat_runtime", 1598 + trace__sched_stat_runtime)) 1599 + goto out_error_tp; 1604 1600 1605 1601 err = perf_evlist__create_maps(evlist, &trace->opts.target); 1606 1602 if (err < 0) { ··· 1713 1717 out: 1714 1718 trace->live = false; 1715 1719 return err; 1720 + out_error_tp: 1721 + switch(errno) { 1722 + case ENOENT: 1723 + fputs("Error:\tUnable to find debugfs\n" 1724 + "Hint:\tWas your kernel was compiled with debugfs support?\n" 1725 + "Hint:\tIs the debugfs filesystem mounted?\n" 1726 + "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'\n", 1727 + trace->output); 1728 + break; 1729 + case EACCES: 1730 + fprintf(trace->output, 1731 + "Error:\tNo permissions to read %s/tracing/events/raw_syscalls\n" 1732 + "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n", 1733 + debugfs_mountpoint, debugfs_mountpoint); 1734 + break; 1735 + default: { 1736 + char bf[256]; 1737 + fprintf(trace->output, "Can't trace: %s\n", 1738 + strerror_r(errno, bf, sizeof(bf))); 1739 + } 1740 + break; 1741 + } 1742 + goto out_delete_evlist; 1716 1743 } 1717 1744 1718 1745 static int trace__replay(struct trace *trace)