Skip to content

Commit

Permalink
tools lib fs debugfs: Introduce debugfs__strerror_open_tp
Browse files Browse the repository at this point in the history
There will be other cases where not just a tracepoint event is being
opened below the debugfs mountpoint, but it is rather common, so provide
one helper for that.

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-q6e6zct49ql6nbcw8kkg0lbj@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 22, 2015
1 parent 5ed08da commit 2cc990b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
9 changes: 9 additions & 0 deletions tools/lib/api/fs/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,12 @@ int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename

return 0;
}

int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
{
char path[PATH_MAX];

snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*");

return debugfs__strerror_open(err, buf, size, path);
}
1 change: 1 addition & 0 deletions tools/lib/api/fs/debugfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ char *debugfs_mount(const char *mountpoint);
extern char debugfs_mountpoint[];

int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename);
int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);

#endif /* __API_DEBUGFS_H__ */
13 changes: 8 additions & 5 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2071,9 +2071,9 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
goto out_error_mem;

if (trace->sched &&
perf_evlist__add_newtp(evlist, "sched", "sched_stat_runtime",
trace__sched_stat_runtime))
goto out_error_tp;
perf_evlist__add_newtp(evlist, "sched", "sched_stat_runtime",
trace__sched_stat_runtime))
goto out_error_sched_stat_runtime;

err = perf_evlist__create_maps(evlist, &trace->opts.target);
if (err < 0) {
Expand Down Expand Up @@ -2203,9 +2203,12 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
{
char errbuf[BUFSIZ];

out_error_tp:
out_error_sched_stat_runtime:
debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
goto out_error;

out_error_raw_syscalls:
debugfs__strerror_open(errno, errbuf, sizeof(errbuf), "tracing/events/raw_syscalls");
debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "raw_syscalls", "sys_(enter|exit)");
goto out_error;

out_error_mmap:
Expand Down

0 comments on commit 2cc990b

Please sign in to comment.