From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, tglx@linutronix.de, namhyung@kernel.org,
a.p.zijlstra@chello.nl, matt@codeblueprint.co.uk,
mingo@kernel.org, raphael.beamonte@gmail.com, dsahern@gmail.com,
jolsa@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org
Subject: [tip:perf/core] perf tools: Add tracing_path and remove unneeded functions
Date: Mon, 31 Aug 2015 01:32:41 -0700 [thread overview]
Message-ID: <tip-9f44f0cc1c32f1542071447a9493652bbc03facb@git.kernel.org> (raw)
In-Reply-To: <1440596813-12844-3-git-send-email-jolsa@kernel.org>
Commit-ID: 9f44f0cc1c32f1542071447a9493652bbc03facb
Gitweb: http://git.kernel.org/tip/9f44f0cc1c32f1542071447a9493652bbc03facb
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 26 Aug 2015 15:46:44 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 28 Aug 2015 14:53:51 -0300
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>
---
tools/perf/util/util.c | 56 ++++----------------------------------------------
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 f7adf12..d33c341 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");
}
@@ -440,62 +443,11 @@ void perf_debugfs_set_path(const char *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;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 88a8915..291be1d 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -83,10 +83,10 @@
extern const char *graph_line;
extern const char *graph_dotted_line;
extern char buildid_dir[];
+extern char tracing_path[];
extern char tracing_events_path[];
extern void perf_debugfs_set_path(const char *mountpoint);
const char *perf_debugfs_mount(const char *mountpoint);
-const char *find_tracing_dir(void);
char *get_tracing_file(const char *name);
void put_tracing_file(char *file);
next prev parent reply other threads:[~2015-08-31 8:33 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-26 13:46 [RFC 00/11] perf tools: Enhance parsing events tracepoint error output Jiri Olsa
2015-08-26 13:46 ` [PATCH 01/11] tools: Add err.h with ERR_PTR PTR_ERR interface Jiri Olsa
2015-08-28 16:21 ` Arnaldo Carvalho de Melo
2015-08-31 7:37 ` Jiri Olsa
2015-08-31 15:27 ` Arnaldo Carvalho de Melo
2015-08-26 13:46 ` [PATCH 02/11] perf tools: Add tracing_path and remove unneeded functions Jiri Olsa
2015-08-27 22:47 ` Matt Fleming
2015-08-28 16:27 ` Arnaldo Carvalho de Melo
2015-08-29 10:25 ` Jiri Olsa
2015-08-31 8:32 ` tip-bot for Jiri Olsa [this message]
2015-08-26 13:46 ` [PATCH 03/11] perf tools: Do not change lib/api/fs/debugfs directly Jiri Olsa
[not found] ` <CAE_Gge2cn8LpuETTTkf2nP8JLj=9RDiuW3M8BXzv7ZTJpY9x7w@mail.gmail.com>
2015-08-26 14:17 ` Jiri Olsa
2015-08-26 14:27 ` Arnaldo Carvalho de Melo
2015-08-28 12:26 ` Matt Fleming
2015-08-28 12:19 ` Matt Fleming
2015-08-31 8:33 ` [tip:perf/core] perf tools: Do not change lib/api/fs/ debugfs directly tip-bot for Jiri Olsa
2015-08-26 13:46 ` [PATCH 04/11] perf tools: Move debugfs__strerror_open into util.c object Jiri Olsa
2015-08-26 13:52 ` Arnaldo Carvalho de Melo
2015-08-26 14:16 ` Jiri Olsa
2015-08-28 12:59 ` Matt Fleming
2015-08-26 13:46 ` [PATCH 05/11] perf tools: Move tracing_path stuff under same namespace Jiri Olsa
2015-08-26 14:42 ` Arnaldo Carvalho de Melo
2015-08-26 14:48 ` Jiri Olsa
2015-08-26 14:58 ` Arnaldo Carvalho de Melo
2015-08-26 15:06 ` Jiri Olsa
2015-08-28 13:06 ` Matt Fleming
2015-08-31 7:43 ` Jiri Olsa
2015-08-26 13:46 ` [PATCH 06/11] perf tools: Move tracing_path interface into trace-event-path.c Jiri Olsa
2015-08-26 13:46 ` [PATCH 07/11] perf tools: Make tracing_path_strerror_open message generic Jiri Olsa
2015-08-26 13:46 ` [PATCH 08/11] perf tools: Do not export debugfs_mountpoint and tracefs_mountpoint Jiri Olsa
2015-08-26 13:46 ` [PATCH 09/11] perf tools: Propagate error info for the tracepoint parsing Jiri Olsa
2015-08-28 13:20 ` Matt Fleming
2015-08-28 13:32 ` Jiri Olsa
2015-08-26 13:46 ` [PATCH 10/11] perf tools: Propagate error info from tp_format Jiri Olsa
2015-08-26 13:46 ` [PATCH 11/11] perf tools: Enhance parsing events tracepoint error output Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-9f44f0cc1c32f1542071447a9493652bbc03facb@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=raphael.beamonte@gmail.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox