diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-08-26 09:46:44 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-08-28 13:53:51 -0400 |
commit | 9f44f0cc1c32f1542071447a9493652bbc03facb (patch) | |
tree | 9297db712188a22d7339b286610f2fd6d409fc0f /tools | |
parent | 0b5a7935f3b5b7d40293b02c3e552f3d67af208b (diff) |
perf tools: Add tracing_path and remove unneeded functions
There's no need for find_tracing_dir, because perf already searches for
debugfs/tracefs mount on start and populate tracing_events_path.
Adding tracing_path to carry tracing dir string to be used in
get_tracing_file instead of calling find_tracing_dir.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1440596813-12844-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/util.c | 56 | ||||
-rw-r--r-- | tools/perf/util/util.h | 2 |
2 files changed, 5 insertions, 53 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index f7adf1203df1..d33c34196a5a 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -34,6 +34,7 @@ bool test_attr__enabled; | |||
34 | bool perf_host = true; | 34 | bool perf_host = true; |
35 | bool perf_guest = false; | 35 | bool perf_guest = false; |
36 | 36 | ||
37 | char tracing_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing"; | ||
37 | char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events"; | 38 | char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events"; |
38 | 39 | ||
39 | void event_attr_init(struct perf_event_attr *attr) | 40 | void event_attr_init(struct perf_event_attr *attr) |
@@ -391,6 +392,8 @@ void set_term_quiet_input(struct termios *old) | |||
391 | 392 | ||
392 | static void set_tracing_events_path(const char *tracing, const char *mountpoint) | 393 | static void set_tracing_events_path(const char *tracing, const char *mountpoint) |
393 | { | 394 | { |
395 | snprintf(tracing_path, sizeof(tracing_path), "%s/%s", | ||
396 | mountpoint, tracing); | ||
394 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s", | 397 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s", |
395 | mountpoint, tracing, "events"); | 398 | mountpoint, tracing, "events"); |
396 | } | 399 | } |
@@ -440,62 +443,11 @@ void perf_debugfs_set_path(const char *mntpt) | |||
440 | set_tracing_events_path("tracing/", mntpt); | 443 | set_tracing_events_path("tracing/", mntpt); |
441 | } | 444 | } |
442 | 445 | ||
443 | static const char *find_tracefs(void) | ||
444 | { | ||
445 | const char *path = __perf_tracefs_mount(NULL); | ||
446 | |||
447 | return path; | ||
448 | } | ||
449 | |||
450 | static const char *find_debugfs(void) | ||
451 | { | ||
452 | const char *path = __perf_debugfs_mount(NULL); | ||
453 | |||
454 | if (!path) | ||
455 | fprintf(stderr, "Your kernel does not support the debugfs filesystem"); | ||
456 | |||
457 | return path; | ||
458 | } | ||
459 | |||
460 | /* | ||
461 | * Finds the path to the debugfs/tracing | ||
462 | * Allocates the string and stores it. | ||
463 | */ | ||
464 | const char *find_tracing_dir(void) | ||
465 | { | ||
466 | const char *tracing_dir = ""; | ||
467 | static char *tracing; | ||
468 | static int tracing_found; | ||
469 | const char *debugfs; | ||
470 | |||
471 | if (tracing_found) | ||
472 | return tracing; | ||
473 | |||
474 | debugfs = find_tracefs(); | ||
475 | if (!debugfs) { | ||
476 | tracing_dir = "/tracing"; | ||
477 | debugfs = find_debugfs(); | ||
478 | if (!debugfs) | ||
479 | return NULL; | ||
480 | } | ||
481 | |||
482 | if (asprintf(&tracing, "%s%s", debugfs, tracing_dir) < 0) | ||
483 | return NULL; | ||
484 | |||
485 | tracing_found = 1; | ||
486 | return tracing; | ||
487 | } | ||
488 | |||
489 | char *get_tracing_file(const char *name) | 446 | char *get_tracing_file(const char *name) |
490 | { | 447 | { |
491 | const char *tracing; | ||
492 | char *file; | 448 | char *file; |
493 | 449 | ||
494 | tracing = find_tracing_dir(); | 450 | if (asprintf(&file, "%s/%s", tracing_path, name) < 0) |
495 | if (!tracing) | ||
496 | return NULL; | ||
497 | |||
498 | if (asprintf(&file, "%s/%s", tracing, name) < 0) | ||
499 | return NULL; | 451 | return NULL; |
500 | 452 | ||
501 | return file; | 453 | return file; |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 88a891562a47..291be1d84bc3 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -83,10 +83,10 @@ | |||
83 | extern const char *graph_line; | 83 | extern const char *graph_line; |
84 | extern const char *graph_dotted_line; | 84 | extern const char *graph_dotted_line; |
85 | extern char buildid_dir[]; | 85 | extern char buildid_dir[]; |
86 | extern char tracing_path[]; | ||
86 | extern char tracing_events_path[]; | 87 | extern char tracing_events_path[]; |
87 | extern void perf_debugfs_set_path(const char *mountpoint); | 88 | extern void perf_debugfs_set_path(const char *mountpoint); |
88 | const char *perf_debugfs_mount(const char *mountpoint); | 89 | const char *perf_debugfs_mount(const char *mountpoint); |
89 | const char *find_tracing_dir(void); | ||
90 | char *get_tracing_file(const char *name); | 90 | char *get_tracing_file(const char *name); |
91 | void put_tracing_file(char *file); | 91 | void put_tracing_file(char *file); |
92 | 92 | ||