aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/lib/api/fs/debugfs.c27
-rw-r--r--tools/lib/api/fs/debugfs.h2
-rw-r--r--tools/perf/builtin-trace.c11
-rw-r--r--tools/perf/util/evlist.c27
-rw-r--r--tools/perf/util/evlist.h1
5 files changed, 38 insertions, 30 deletions
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index 86ea2d7b8845..fb700eed61c2 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -1,3 +1,4 @@
1#define _GNU_SOURCE
1#include <errno.h> 2#include <errno.h>
2#include <stdio.h> 3#include <stdio.h>
3#include <stdlib.h> 4#include <stdlib.h>
@@ -98,3 +99,29 @@ char *debugfs_mount(const char *mountpoint)
98out: 99out:
99 return debugfs_mountpoint; 100 return debugfs_mountpoint;
100} 101}
102
103int debugfs__strerror_open(int err, char *buf, size_t size)
104{
105 char sbuf[128];
106
107 switch (err) {
108 case ENOENT:
109 snprintf(buf, size, "%s",
110 "Error:\tUnable to find debugfs\n"
111 "Hint:\tWas your kernel compiled with debugfs support?\n"
112 "Hint:\tIs the debugfs filesystem mounted?\n"
113 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
114 break;
115 case EACCES:
116 snprintf(buf, size,
117 "Error:\tNo permissions to read %s/tracing/events/raw_syscalls\n"
118 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
119 debugfs_mountpoint, debugfs_mountpoint);
120 break;
121 default:
122 snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
123 break;
124 }
125
126 return 0;
127}
diff --git a/tools/lib/api/fs/debugfs.h b/tools/lib/api/fs/debugfs.h
index f19d3df9609d..afa5043fec61 100644
--- a/tools/lib/api/fs/debugfs.h
+++ b/tools/lib/api/fs/debugfs.h
@@ -26,4 +26,6 @@ char *debugfs_mount(const char *mountpoint);
26 26
27extern char debugfs_mountpoint[]; 27extern char debugfs_mountpoint[];
28 28
29int debugfs__strerror_open(int err, char *buf, size_t size);
30
29#endif /* __API_DEBUGFS_H__ */ 31#endif /* __API_DEBUGFS_H__ */
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 258f6550c736..2f82dd78b086 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2062,8 +2062,15 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
2062 perf_evlist__add_vfs_getname(evlist); 2062 perf_evlist__add_vfs_getname(evlist);
2063 2063
2064 if ((trace->trace_pgfaults & TRACE_PFMAJ) && 2064 if ((trace->trace_pgfaults & TRACE_PFMAJ) &&
2065 perf_evlist__add_pgfault(evlist, PERF_COUNT_SW_PAGE_FAULTS_MAJ)) 2065 perf_evlist__add_pgfault(evlist, PERF_COUNT_SW_PAGE_FAULTS_MAJ)) {
2066 /*
2067 * FIXME: This one needs better error handling, as by now we
2068 * already checked that debugfs is mounted and that we have access to it,
2069 * so probably the case is that something is busted wrt this specific
2070 * software event, ditto for the next gotos to out_error_tp...
2071 */
2066 goto out_error_tp; 2072 goto out_error_tp;
2073 }
2067 2074
2068 if ((trace->trace_pgfaults & TRACE_PFMIN) && 2075 if ((trace->trace_pgfaults & TRACE_PFMIN) &&
2069 perf_evlist__add_pgfault(evlist, PERF_COUNT_SW_PAGE_FAULTS_MIN)) 2076 perf_evlist__add_pgfault(evlist, PERF_COUNT_SW_PAGE_FAULTS_MIN))
@@ -2203,7 +2210,7 @@ out:
2203 char errbuf[BUFSIZ]; 2210 char errbuf[BUFSIZ];
2204 2211
2205out_error_tp: 2212out_error_tp:
2206 perf_evlist__strerror_tp(evlist, errno, errbuf, sizeof(errbuf)); 2213 debugfs__strerror_open(errno, errbuf, sizeof(errbuf));
2207 goto out_error; 2214 goto out_error;
2208 2215
2209out_error_mmap: 2216out_error_mmap:
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 2e507b5025a3..28b8ce86bf12 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1436,33 +1436,6 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp)
1436 return printed + fprintf(fp, "\n"); 1436 return printed + fprintf(fp, "\n");
1437} 1437}
1438 1438
1439int perf_evlist__strerror_tp(struct perf_evlist *evlist __maybe_unused,
1440 int err, char *buf, size_t size)
1441{
1442 char sbuf[128];
1443
1444 switch (err) {
1445 case ENOENT:
1446 scnprintf(buf, size, "%s",
1447 "Error:\tUnable to find debugfs\n"
1448 "Hint:\tWas your kernel compiled with debugfs support?\n"
1449 "Hint:\tIs the debugfs filesystem mounted?\n"
1450 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
1451 break;
1452 case EACCES:
1453 scnprintf(buf, size,
1454 "Error:\tNo permissions to read %s/tracing/events/raw_syscalls\n"
1455 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
1456 debugfs_mountpoint, debugfs_mountpoint);
1457 break;
1458 default:
1459 scnprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
1460 break;
1461 }
1462
1463 return 0;
1464}
1465
1466int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused, 1439int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused,
1467 int err, char *buf, size_t size) 1440 int err, char *buf, size_t size)
1468{ 1441{
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 0ba93f67ab94..c94a9e03ecf1 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -183,7 +183,6 @@ static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist)
183 183
184size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp); 184size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
185 185
186int perf_evlist__strerror_tp(struct perf_evlist *evlist, int err, char *buf, size_t size);
187int perf_evlist__strerror_open(struct perf_evlist *evlist, int err, char *buf, size_t size); 186int perf_evlist__strerror_open(struct perf_evlist *evlist, int err, char *buf, size_t size);
188int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, size_t size); 187int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, size_t size);
189 188