diff options
author | Clark Williams <williams@redhat.com> | 2009-11-08 10:03:07 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-08 12:01:35 -0500 |
commit | 549104f22b3cd4761145eb5fba6ee4d59822da61 (patch) | |
tree | 2966d464ffe82e391fad654d8e91ecf7a40f4367 | |
parent | afe61f677866ffc484e69c4ecca2d316d564d78b (diff) |
perf tools: Modify perf routines to use new debugfs routines
modify perf.c get_debugfs_mntpnt() to use the util/debugfs.c
debugfs_find_mountpoint()
modify util/parse-events.c to use debugfs_valid_mountpoint().
Signed-off-by: Clark Williams <williams@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <20091101155720.624cc87e@torg>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | tools/perf/perf.c | 44 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 17 |
2 files changed, 10 insertions, 51 deletions
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 624e62d9d1e0..601f403fbdac 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include "util/run-command.h" | 14 | #include "util/run-command.h" |
15 | #include "util/parse-events.h" | 15 | #include "util/parse-events.h" |
16 | #include "util/string.h" | 16 | #include "util/string.h" |
17 | #include "util/debugfs.h" | ||
17 | 18 | ||
18 | const char perf_usage_string[] = | 19 | const char perf_usage_string[] = |
19 | "perf [--version] [--help] COMMAND [ARGS]"; | 20 | "perf [--version] [--help] COMMAND [ARGS]"; |
@@ -382,45 +383,12 @@ static int run_argv(int *argcp, const char ***argv) | |||
382 | /* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */ | 383 | /* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */ |
383 | static void get_debugfs_mntpt(void) | 384 | static void get_debugfs_mntpt(void) |
384 | { | 385 | { |
385 | FILE *file; | 386 | const char *path = debugfs_find_mountpoint(); |
386 | char fs_type[100]; | ||
387 | char debugfs[MAXPATHLEN]; | ||
388 | 387 | ||
389 | /* | 388 | if (path) |
390 | * try the standard location | 389 | strncpy(debugfs_mntpt, path, sizeof(debugfs_mntpt)); |
391 | */ | 390 | else |
392 | if (valid_debugfs_mount("/sys/kernel/debug/") == 0) { | 391 | debugfs_mntpt[0] = '\0'; |
393 | strcpy(debugfs_mntpt, "/sys/kernel/debug/"); | ||
394 | return; | ||
395 | } | ||
396 | |||
397 | /* | ||
398 | * try the sane location | ||
399 | */ | ||
400 | if (valid_debugfs_mount("/debug/") == 0) { | ||
401 | strcpy(debugfs_mntpt, "/debug/"); | ||
402 | return; | ||
403 | } | ||
404 | |||
405 | /* | ||
406 | * give up and parse /proc/mounts | ||
407 | */ | ||
408 | file = fopen("/proc/mounts", "r"); | ||
409 | if (file == NULL) | ||
410 | return; | ||
411 | |||
412 | while (fscanf(file, "%*s %" | ||
413 | STR(MAXPATHLEN) | ||
414 | "s %99s %*s %*d %*d\n", | ||
415 | debugfs, fs_type) == 2) { | ||
416 | if (strcmp(fs_type, "debugfs") == 0) | ||
417 | break; | ||
418 | } | ||
419 | fclose(file); | ||
420 | if (strcmp(fs_type, "debugfs") == 0) { | ||
421 | strncpy(debugfs_mntpt, debugfs, MAXPATHLEN); | ||
422 | debugfs_mntpt[MAXPATHLEN - 1] = '\0'; | ||
423 | } | ||
424 | } | 392 | } |
425 | 393 | ||
426 | int main(int argc, const char **argv) | 394 | int main(int argc, const char **argv) |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 31baa5a60365..097938a96d74 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "string.h" | 7 | #include "string.h" |
8 | #include "cache.h" | 8 | #include "cache.h" |
9 | #include "header.h" | 9 | #include "header.h" |
10 | #include "debugfs.h" | ||
10 | 11 | ||
11 | int nr_counters; | 12 | int nr_counters; |
12 | 13 | ||
@@ -149,16 +150,6 @@ static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir) | |||
149 | 150 | ||
150 | #define MAX_EVENT_LENGTH 512 | 151 | #define MAX_EVENT_LENGTH 512 |
151 | 152 | ||
152 | int valid_debugfs_mount(const char *debugfs) | ||
153 | { | ||
154 | struct statfs st_fs; | ||
155 | |||
156 | if (statfs(debugfs, &st_fs) < 0) | ||
157 | return -ENOENT; | ||
158 | else if (st_fs.f_type != (long) DEBUGFS_MAGIC) | ||
159 | return -ENOENT; | ||
160 | return 0; | ||
161 | } | ||
162 | 153 | ||
163 | struct tracepoint_path *tracepoint_id_to_path(u64 config) | 154 | struct tracepoint_path *tracepoint_id_to_path(u64 config) |
164 | { | 155 | { |
@@ -171,7 +162,7 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config) | |||
171 | char evt_path[MAXPATHLEN]; | 162 | char evt_path[MAXPATHLEN]; |
172 | char dir_path[MAXPATHLEN]; | 163 | char dir_path[MAXPATHLEN]; |
173 | 164 | ||
174 | if (valid_debugfs_mount(debugfs_path)) | 165 | if (debugfs_valid_mountpoint(debugfs_path)) |
175 | return NULL; | 166 | return NULL; |
176 | 167 | ||
177 | sys_dir = opendir(debugfs_path); | 168 | sys_dir = opendir(debugfs_path); |
@@ -510,7 +501,7 @@ static enum event_result parse_tracepoint_event(const char **strp, | |||
510 | char sys_name[MAX_EVENT_LENGTH]; | 501 | char sys_name[MAX_EVENT_LENGTH]; |
511 | unsigned int sys_length, evt_length; | 502 | unsigned int sys_length, evt_length; |
512 | 503 | ||
513 | if (valid_debugfs_mount(debugfs_path)) | 504 | if (debugfs_valid_mountpoint(debugfs_path)) |
514 | return 0; | 505 | return 0; |
515 | 506 | ||
516 | evt_name = strchr(*strp, ':'); | 507 | evt_name = strchr(*strp, ':'); |
@@ -788,7 +779,7 @@ static void print_tracepoint_events(void) | |||
788 | char evt_path[MAXPATHLEN]; | 779 | char evt_path[MAXPATHLEN]; |
789 | char dir_path[MAXPATHLEN]; | 780 | char dir_path[MAXPATHLEN]; |
790 | 781 | ||
791 | if (valid_debugfs_mount(debugfs_path)) | 782 | if (debugfs_valid_mountpoint(debugfs_path)) |
792 | return; | 783 | return; |
793 | 784 | ||
794 | sys_dir = opendir(debugfs_path); | 785 | sys_dir = opendir(debugfs_path); |