diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-01-22 08:34:22 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-01-22 08:34:22 -0500 |
commit | e2726d99645c5fa1fd9abd6353270fde624696f8 (patch) | |
tree | 81c3ab212b91be44b180d712f43300c101e6e4d3 /tools/perf | |
parent | 566b5cfb035fb496280be61f976b5281563bfa27 (diff) |
tools lib fs: Adopt debugfs open strerrno method
As this is not specific to an evlist and may be used with other tools.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-a9up9mivx1pzdf5tqrqsx62d@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/include/asm/hash.h
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-trace.c | 11 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 27 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 1 |
3 files changed, 9 insertions, 30 deletions
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 | ||
2205 | out_error_tp: | 2212 | out_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 | ||
2209 | out_error_mmap: | 2216 | out_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 | ||
1439 | int 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 | |||
1466 | int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused, | 1439 | int 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 | ||
184 | size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp); | 184 | size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp); |
185 | 185 | ||
186 | int perf_evlist__strerror_tp(struct perf_evlist *evlist, int err, char *buf, size_t size); | ||
187 | int perf_evlist__strerror_open(struct perf_evlist *evlist, int err, char *buf, size_t size); | 186 | int perf_evlist__strerror_open(struct perf_evlist *evlist, int err, char *buf, size_t size); |
188 | int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, size_t size); | 187 | int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, size_t size); |
189 | 188 | ||