diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-16 11:03:07 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-28 07:11:28 -0500 |
commit | ebf294bf4f147aff29df5a16bfb0f8ebca15feaa (patch) | |
tree | 37464624abf9243100eab47fdc663def4be121fe /tools/perf/util/parse-events.c | |
parent | c168fbfb93a1c4044287858c6784f0bd1f6cfe33 (diff) |
perf tools: Simplify debugfs mountpoint handling code
We don't need to have two PATH_MAX char sized arrays holding it, just
one in util/debugfs.c will do.
Also rename debugfs_path to tracing_events_path, as it is not the path
to debugfs, that is debugfs_mountpoint. Both are now accessible.
This will allow accessing this code in the perf python binding without
having to drag in perf.c and util/parse-events.c.
The defaults for these variables are the canonical "/sys/kernel/debug"
and "/sys/kernel/debug/tracing/events/", removing the need for simple
tools to call debugfs_mount(NULL).
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-ug9jvtjrsqbluuhqqxpvg30f@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r-- | tools/perf/util/parse-events.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 928918b796b2..586ab3fe60f8 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -25,8 +25,6 @@ enum event_result { | |||
25 | EVT_HANDLED_ALL | 25 | EVT_HANDLED_ALL |
26 | }; | 26 | }; |
27 | 27 | ||
28 | char debugfs_path[MAXPATHLEN]; | ||
29 | |||
30 | #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x | 28 | #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x |
31 | #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x | 29 | #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x |
32 | 30 | ||
@@ -140,7 +138,7 @@ static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir) | |||
140 | char evt_path[MAXPATHLEN]; | 138 | char evt_path[MAXPATHLEN]; |
141 | int fd; | 139 | int fd; |
142 | 140 | ||
143 | snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path, | 141 | snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", tracing_events_path, |
144 | sys_dir->d_name, evt_dir->d_name); | 142 | sys_dir->d_name, evt_dir->d_name); |
145 | fd = open(evt_path, O_RDONLY); | 143 | fd = open(evt_path, O_RDONLY); |
146 | if (fd < 0) | 144 | if (fd < 0) |
@@ -171,16 +169,16 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config) | |||
171 | char evt_path[MAXPATHLEN]; | 169 | char evt_path[MAXPATHLEN]; |
172 | char dir_path[MAXPATHLEN]; | 170 | char dir_path[MAXPATHLEN]; |
173 | 171 | ||
174 | if (debugfs_valid_mountpoint(debugfs_path)) | 172 | if (debugfs_valid_mountpoint(tracing_events_path)) |
175 | return NULL; | 173 | return NULL; |
176 | 174 | ||
177 | sys_dir = opendir(debugfs_path); | 175 | sys_dir = opendir(tracing_events_path); |
178 | if (!sys_dir) | 176 | if (!sys_dir) |
179 | return NULL; | 177 | return NULL; |
180 | 178 | ||
181 | for_each_subsystem(sys_dir, sys_dirent, sys_next) { | 179 | for_each_subsystem(sys_dir, sys_dirent, sys_next) { |
182 | 180 | ||
183 | snprintf(dir_path, MAXPATHLEN, "%s/%s", debugfs_path, | 181 | snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, |
184 | sys_dirent.d_name); | 182 | sys_dirent.d_name); |
185 | evt_dir = opendir(dir_path); | 183 | evt_dir = opendir(dir_path); |
186 | if (!evt_dir) | 184 | if (!evt_dir) |
@@ -447,7 +445,7 @@ parse_single_tracepoint_event(char *sys_name, | |||
447 | u64 id; | 445 | u64 id; |
448 | int fd; | 446 | int fd; |
449 | 447 | ||
450 | snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path, | 448 | snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", tracing_events_path, |
451 | sys_name, evt_name); | 449 | sys_name, evt_name); |
452 | 450 | ||
453 | fd = open(evt_path, O_RDONLY); | 451 | fd = open(evt_path, O_RDONLY); |
@@ -485,7 +483,7 @@ parse_multiple_tracepoint_event(struct perf_evlist *evlist, char *sys_name, | |||
485 | struct dirent *evt_ent; | 483 | struct dirent *evt_ent; |
486 | DIR *evt_dir; | 484 | DIR *evt_dir; |
487 | 485 | ||
488 | snprintf(evt_path, MAXPATHLEN, "%s/%s", debugfs_path, sys_name); | 486 | snprintf(evt_path, MAXPATHLEN, "%s/%s", tracing_events_path, sys_name); |
489 | evt_dir = opendir(evt_path); | 487 | evt_dir = opendir(evt_path); |
490 | 488 | ||
491 | if (!evt_dir) { | 489 | if (!evt_dir) { |
@@ -528,7 +526,7 @@ parse_tracepoint_event(struct perf_evlist *evlist, const char **strp, | |||
528 | char sys_name[MAX_EVENT_LENGTH]; | 526 | char sys_name[MAX_EVENT_LENGTH]; |
529 | unsigned int sys_length, evt_length; | 527 | unsigned int sys_length, evt_length; |
530 | 528 | ||
531 | if (debugfs_valid_mountpoint(debugfs_path)) | 529 | if (debugfs_valid_mountpoint(tracing_events_path)) |
532 | return 0; | 530 | return 0; |
533 | 531 | ||
534 | evt_name = strchr(*strp, ':'); | 532 | evt_name = strchr(*strp, ':'); |
@@ -920,10 +918,10 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob) | |||
920 | char evt_path[MAXPATHLEN]; | 918 | char evt_path[MAXPATHLEN]; |
921 | char dir_path[MAXPATHLEN]; | 919 | char dir_path[MAXPATHLEN]; |
922 | 920 | ||
923 | if (debugfs_valid_mountpoint(debugfs_path)) | 921 | if (debugfs_valid_mountpoint(tracing_events_path)) |
924 | return; | 922 | return; |
925 | 923 | ||
926 | sys_dir = opendir(debugfs_path); | 924 | sys_dir = opendir(tracing_events_path); |
927 | if (!sys_dir) | 925 | if (!sys_dir) |
928 | return; | 926 | return; |
929 | 927 | ||
@@ -932,7 +930,7 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob) | |||
932 | !strglobmatch(sys_dirent.d_name, subsys_glob)) | 930 | !strglobmatch(sys_dirent.d_name, subsys_glob)) |
933 | continue; | 931 | continue; |
934 | 932 | ||
935 | snprintf(dir_path, MAXPATHLEN, "%s/%s", debugfs_path, | 933 | snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, |
936 | sys_dirent.d_name); | 934 | sys_dirent.d_name); |
937 | evt_dir = opendir(dir_path); | 935 | evt_dir = opendir(dir_path); |
938 | if (!evt_dir) | 936 | if (!evt_dir) |
@@ -964,16 +962,16 @@ int is_valid_tracepoint(const char *event_string) | |||
964 | char evt_path[MAXPATHLEN]; | 962 | char evt_path[MAXPATHLEN]; |
965 | char dir_path[MAXPATHLEN]; | 963 | char dir_path[MAXPATHLEN]; |
966 | 964 | ||
967 | if (debugfs_valid_mountpoint(debugfs_path)) | 965 | if (debugfs_valid_mountpoint(tracing_events_path)) |
968 | return 0; | 966 | return 0; |
969 | 967 | ||
970 | sys_dir = opendir(debugfs_path); | 968 | sys_dir = opendir(tracing_events_path); |
971 | if (!sys_dir) | 969 | if (!sys_dir) |
972 | return 0; | 970 | return 0; |
973 | 971 | ||
974 | for_each_subsystem(sys_dir, sys_dirent, sys_next) { | 972 | for_each_subsystem(sys_dir, sys_dirent, sys_next) { |
975 | 973 | ||
976 | snprintf(dir_path, MAXPATHLEN, "%s/%s", debugfs_path, | 974 | snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, |
977 | sys_dirent.d_name); | 975 | sys_dirent.d_name); |
978 | evt_dir = opendir(dir_path); | 976 | evt_dir = opendir(dir_path); |
979 | if (!evt_dir) | 977 | if (!evt_dir) |