diff options
author | Borislav Petkov <bp@suse.de> | 2013-02-20 16:32:31 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-15 13:06:01 -0300 |
commit | 1355915ac626da30a0c02ccd4569c1e5ce2cbb82 (patch) | |
tree | 37a7cb0618572c4c45d0ec6949cdda6253694291 /tools/perf/util | |
parent | 85c66be101e1847f0eb46dcb48d5738572129694 (diff) |
perf tools: Extract perf-specific stuff from debugfs.c
Move them to util.c and simplify code a bit.
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1361374353-30385-6-git-send-email-bp@alien8.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/trace-event-info.c | 2 | ||||
-rw-r--r-- | tools/perf/util/util.c | 27 | ||||
-rw-r--r-- | tools/perf/util/util.h | 7 |
3 files changed, 33 insertions, 3 deletions
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index 36b9b49d0177..5c1509ab0c29 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c @@ -80,7 +80,7 @@ static void *malloc_or_die(unsigned int size) static const char *find_debugfs(void) { - const char *path = debugfs_mount(NULL); + const char *path = perf_debugfs_mount(NULL); if (!path) die("Your kernel not support debugfs filesystem"); diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 805d1f52c5b4..59d868add275 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -17,6 +17,8 @@ bool test_attr__enabled; bool perf_host = true; bool perf_guest = false; +char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events"; + void event_attr_init(struct perf_event_attr *attr) { if (!perf_host) @@ -242,3 +244,28 @@ void get_term_dimensions(struct winsize *ws) ws->ws_row = 25; ws->ws_col = 80; } + +static void set_tracing_events_path(const char *mountpoint) +{ + snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s", + mountpoint, "tracing/events"); +} + +const char *perf_debugfs_mount(const char *mountpoint) +{ + const char *mnt; + + mnt = debugfs_mount(mountpoint); + if (!mnt) + return NULL; + + set_tracing_events_path(mnt); + + return mnt; +} + +void perf_debugfs_set_path(const char *mntpt) +{ + snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt); + set_tracing_events_path(mntpt); +} diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 09b4c26b71aa..6a0781c3a573 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -73,10 +73,14 @@ #include <linux/magic.h> #include "types.h" #include <sys/ttydefaults.h> +#include <lk/debugfs.h> extern const char *graph_line; extern const char *graph_dotted_line; extern char buildid_dir[]; +extern char tracing_events_path[]; +extern void perf_debugfs_set_path(const char *mountpoint); +const char *perf_debugfs_mount(const char *mountpoint); /* On most systems <limits.h> would have given us this, but * not on some systems (e.g. GNU/Hurd). @@ -274,5 +278,4 @@ extern unsigned int page_size; struct winsize; void get_term_dimensions(struct winsize *ws); - -#endif +#endif /* GIT_COMPAT_UTIL_H */ |