diff options
author | Borislav Petkov <bp@suse.de> | 2013-02-20 10:32:31 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-15 12:06:01 -0400 |
commit | 1355915ac626da30a0c02ccd4569c1e5ce2cbb82 (patch) | |
tree | 37a7cb0618572c4c45d0ec6949cdda6253694291 /tools | |
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')
-rw-r--r-- | tools/lib/lk/debugfs.c | 15 | ||||
-rw-r--r-- | tools/lib/lk/debugfs.h | 2 | ||||
-rw-r--r-- | tools/perf/perf.c | 6 | ||||
-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 |
6 files changed, 36 insertions, 23 deletions
diff --git a/tools/lib/lk/debugfs.c b/tools/lib/lk/debugfs.c index 9cda7a6f5917..099e7cd022e4 100644 --- a/tools/lib/lk/debugfs.c +++ b/tools/lib/lk/debugfs.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include "debugfs.h" | 11 | #include "debugfs.h" |
12 | 12 | ||
13 | char debugfs_mountpoint[PATH_MAX + 1] = "/sys/kernel/debug"; | 13 | char debugfs_mountpoint[PATH_MAX + 1] = "/sys/kernel/debug"; |
14 | char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events"; | ||
15 | 14 | ||
16 | static const char * const debugfs_known_mountpoints[] = { | 15 | static const char * const debugfs_known_mountpoints[] = { |
17 | "/sys/kernel/debug/", | 16 | "/sys/kernel/debug/", |
@@ -75,14 +74,7 @@ int debugfs_valid_mountpoint(const char *debugfs) | |||
75 | return 0; | 74 | return 0; |
76 | } | 75 | } |
77 | 76 | ||
78 | static void debugfs_set_tracing_events_path(const char *mountpoint) | ||
79 | { | ||
80 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s", | ||
81 | mountpoint, "tracing/events"); | ||
82 | } | ||
83 | |||
84 | /* mount the debugfs somewhere if it's not mounted */ | 77 | /* mount the debugfs somewhere if it's not mounted */ |
85 | |||
86 | char *debugfs_mount(const char *mountpoint) | 78 | char *debugfs_mount(const char *mountpoint) |
87 | { | 79 | { |
88 | /* see if it's already mounted */ | 80 | /* see if it's already mounted */ |
@@ -105,12 +97,5 @@ char *debugfs_mount(const char *mountpoint) | |||
105 | debugfs_found = true; | 97 | debugfs_found = true; |
106 | strncpy(debugfs_mountpoint, mountpoint, sizeof(debugfs_mountpoint)); | 98 | strncpy(debugfs_mountpoint, mountpoint, sizeof(debugfs_mountpoint)); |
107 | out: | 99 | out: |
108 | debugfs_set_tracing_events_path(debugfs_mountpoint); | ||
109 | return debugfs_mountpoint; | 100 | return debugfs_mountpoint; |
110 | } | 101 | } |
111 | |||
112 | void debugfs_set_path(const char *mountpoint) | ||
113 | { | ||
114 | snprintf(debugfs_mountpoint, sizeof(debugfs_mountpoint), "%s", mountpoint); | ||
115 | debugfs_set_tracing_events_path(mountpoint); | ||
116 | } | ||
diff --git a/tools/lib/lk/debugfs.h b/tools/lib/lk/debugfs.h index bc5ad2df7c0a..935c59bdb442 100644 --- a/tools/lib/lk/debugfs.h +++ b/tools/lib/lk/debugfs.h | |||
@@ -23,9 +23,7 @@ | |||
23 | const char *debugfs_find_mountpoint(void); | 23 | const char *debugfs_find_mountpoint(void); |
24 | int debugfs_valid_mountpoint(const char *debugfs); | 24 | int debugfs_valid_mountpoint(const char *debugfs); |
25 | char *debugfs_mount(const char *mountpoint); | 25 | char *debugfs_mount(const char *mountpoint); |
26 | void debugfs_set_path(const char *mountpoint); | ||
27 | 26 | ||
28 | extern char debugfs_mountpoint[]; | 27 | extern char debugfs_mountpoint[]; |
29 | extern char tracing_events_path[]; | ||
30 | 28 | ||
31 | #endif /* __LK_DEBUGFS_H__ */ | 29 | #endif /* __LK_DEBUGFS_H__ */ |
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index f53b735e2822..f6ba7b73f40e 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -193,13 +193,13 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) | |||
193 | fprintf(stderr, "No directory given for --debugfs-dir.\n"); | 193 | fprintf(stderr, "No directory given for --debugfs-dir.\n"); |
194 | usage(perf_usage_string); | 194 | usage(perf_usage_string); |
195 | } | 195 | } |
196 | debugfs_set_path((*argv)[1]); | 196 | perf_debugfs_set_path((*argv)[1]); |
197 | if (envchanged) | 197 | if (envchanged) |
198 | *envchanged = 1; | 198 | *envchanged = 1; |
199 | (*argv)++; | 199 | (*argv)++; |
200 | (*argc)--; | 200 | (*argc)--; |
201 | } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) { | 201 | } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) { |
202 | debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR)); | 202 | perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR)); |
203 | fprintf(stderr, "dir: %s\n", debugfs_mountpoint); | 203 | fprintf(stderr, "dir: %s\n", debugfs_mountpoint); |
204 | if (envchanged) | 204 | if (envchanged) |
205 | *envchanged = 1; | 205 | *envchanged = 1; |
@@ -461,7 +461,7 @@ int main(int argc, const char **argv) | |||
461 | if (!cmd) | 461 | if (!cmd) |
462 | cmd = "perf-help"; | 462 | cmd = "perf-help"; |
463 | /* get debugfs mount point from /proc/mounts */ | 463 | /* get debugfs mount point from /proc/mounts */ |
464 | debugfs_mount(NULL); | 464 | perf_debugfs_mount(NULL); |
465 | /* | 465 | /* |
466 | * "perf-xxxx" is the same as "perf xxxx", but we obviously: | 466 | * "perf-xxxx" is the same as "perf xxxx", but we obviously: |
467 | * | 467 | * |
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) | |||
80 | 80 | ||
81 | static const char *find_debugfs(void) | 81 | static const char *find_debugfs(void) |
82 | { | 82 | { |
83 | const char *path = debugfs_mount(NULL); | 83 | const char *path = perf_debugfs_mount(NULL); |
84 | 84 | ||
85 | if (!path) | 85 | if (!path) |
86 | die("Your kernel not support debugfs filesystem"); | 86 | 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; | |||
17 | bool perf_host = true; | 17 | bool perf_host = true; |
18 | bool perf_guest = false; | 18 | bool perf_guest = false; |
19 | 19 | ||
20 | char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events"; | ||
21 | |||
20 | void event_attr_init(struct perf_event_attr *attr) | 22 | void event_attr_init(struct perf_event_attr *attr) |
21 | { | 23 | { |
22 | if (!perf_host) | 24 | if (!perf_host) |
@@ -242,3 +244,28 @@ void get_term_dimensions(struct winsize *ws) | |||
242 | ws->ws_row = 25; | 244 | ws->ws_row = 25; |
243 | ws->ws_col = 80; | 245 | ws->ws_col = 80; |
244 | } | 246 | } |
247 | |||
248 | static void set_tracing_events_path(const char *mountpoint) | ||
249 | { | ||
250 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s", | ||
251 | mountpoint, "tracing/events"); | ||
252 | } | ||
253 | |||
254 | const char *perf_debugfs_mount(const char *mountpoint) | ||
255 | { | ||
256 | const char *mnt; | ||
257 | |||
258 | mnt = debugfs_mount(mountpoint); | ||
259 | if (!mnt) | ||
260 | return NULL; | ||
261 | |||
262 | set_tracing_events_path(mnt); | ||
263 | |||
264 | return mnt; | ||
265 | } | ||
266 | |||
267 | void perf_debugfs_set_path(const char *mntpt) | ||
268 | { | ||
269 | snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt); | ||
270 | set_tracing_events_path(mntpt); | ||
271 | } | ||
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 @@ | |||
73 | #include <linux/magic.h> | 73 | #include <linux/magic.h> |
74 | #include "types.h" | 74 | #include "types.h" |
75 | #include <sys/ttydefaults.h> | 75 | #include <sys/ttydefaults.h> |
76 | #include <lk/debugfs.h> | ||
76 | 77 | ||
77 | extern const char *graph_line; | 78 | extern const char *graph_line; |
78 | extern const char *graph_dotted_line; | 79 | extern const char *graph_dotted_line; |
79 | extern char buildid_dir[]; | 80 | extern char buildid_dir[]; |
81 | extern char tracing_events_path[]; | ||
82 | extern void perf_debugfs_set_path(const char *mountpoint); | ||
83 | const char *perf_debugfs_mount(const char *mountpoint); | ||
80 | 84 | ||
81 | /* On most systems <limits.h> would have given us this, but | 85 | /* On most systems <limits.h> would have given us this, but |
82 | * not on some systems (e.g. GNU/Hurd). | 86 | * not on some systems (e.g. GNU/Hurd). |
@@ -274,5 +278,4 @@ extern unsigned int page_size; | |||
274 | 278 | ||
275 | struct winsize; | 279 | struct winsize; |
276 | void get_term_dimensions(struct winsize *ws); | 280 | void get_term_dimensions(struct winsize *ws); |
277 | 281 | #endif /* GIT_COMPAT_UTIL_H */ | |
278 | #endif | ||