summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/util.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2015-08-31 10:25:46 +0200
committerIngo Molnar <mingo@kernel.org>2015-08-31 10:25:46 +0200
commitbac2e4a96d1c0bcce5e9654dcc902f75576b9b03 (patch)
tree1ca98d982c8cbcf25db713fc8439d7772fe97383 /tools/perf/util/util.c
parent02b643b643254ec79b5f9aaa143e10be68eabdab (diff)
parent2c07144dfce366e21465cc7b0ada9f0b6dc7b7ed (diff)
downloadlinux-bac2e4a96d1c0bcce5e9654dcc902f75576b9b03.tar.bz2
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvement and fixes from Arnaldo Carvalho de Melo: User visible changes: - Add new compaction-times python script. (Tony Jones) - Make the --[no-]-demangle/--[no-]-demangle-kernel command line options available in 'perf script' too. (Mark Drayton) - Allow for negative numbers in libtraceevent's print format, fixing up misformatting in some tracepoints. (Steven Rostedt) Infrastructure changes: - perf_env/perf_evlist changes to allow accessing the data structure with the environment where some perf data was collected in functions not necessarily related to perf.data file processing. (Kan Liang) - Cleanups for the tracepoint definition location paths routines. (Jiri Olsa) - Introduce sysfs/filename__sprintf_build_id, removing code duplication. (Masami Hiramatsu) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r--tools/perf/util/util.c57
1 files changed, 4 insertions, 53 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index f7adf1203df1..7acafb3c5592 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -34,6 +34,7 @@ bool test_attr__enabled;
bool perf_host = true;
bool perf_guest = false;
+char tracing_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing";
char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
void event_attr_init(struct perf_event_attr *attr)
@@ -391,6 +392,8 @@ void set_term_quiet_input(struct termios *old)
static void set_tracing_events_path(const char *tracing, const char *mountpoint)
{
+ snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
+ mountpoint, tracing);
snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
mountpoint, tracing, "events");
}
@@ -436,66 +439,14 @@ const char *perf_debugfs_mount(const char *mountpoint)
void perf_debugfs_set_path(const char *mntpt)
{
- snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt);
set_tracing_events_path("tracing/", mntpt);
}
-static const char *find_tracefs(void)
-{
- const char *path = __perf_tracefs_mount(NULL);
-
- return path;
-}
-
-static const char *find_debugfs(void)
-{
- const char *path = __perf_debugfs_mount(NULL);
-
- if (!path)
- fprintf(stderr, "Your kernel does not support the debugfs filesystem");
-
- return path;
-}
-
-/*
- * Finds the path to the debugfs/tracing
- * Allocates the string and stores it.
- */
-const char *find_tracing_dir(void)
-{
- const char *tracing_dir = "";
- static char *tracing;
- static int tracing_found;
- const char *debugfs;
-
- if (tracing_found)
- return tracing;
-
- debugfs = find_tracefs();
- if (!debugfs) {
- tracing_dir = "/tracing";
- debugfs = find_debugfs();
- if (!debugfs)
- return NULL;
- }
-
- if (asprintf(&tracing, "%s%s", debugfs, tracing_dir) < 0)
- return NULL;
-
- tracing_found = 1;
- return tracing;
-}
-
char *get_tracing_file(const char *name)
{
- const char *tracing;
char *file;
- tracing = find_tracing_dir();
- if (!tracing)
- return NULL;
-
- if (asprintf(&file, "%s/%s", tracing, name) < 0)
+ if (asprintf(&file, "%s/%s", tracing_path, name) < 0)
return NULL;
return file;