From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 03/18] tools lib api: Unexport 'tracing_path' variable
Date: Sat, 19 May 2018 07:54:52 -0300 [thread overview]
Message-ID: <20180519105507.16450-4-acme@kernel.org> (raw)
In-Reply-To: <20180519105507.16450-1-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
One should use tracing_path_mount() instead, so more things get done
lazily instead of at every 'perf' tool call startup.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-fci4yll35idd9yuslp67vqc2@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/api/fs/tracing_path.c | 4 ++--
tools/lib/api/fs/tracing_path.h | 1 -
tools/perf/perf.c | 5 +----
tools/perf/util/probe-file.c | 3 +--
4 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 4f8ec7d476b8..6f5fe942eff4 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -14,7 +14,7 @@
#include "tracing_path.h"
static char tracing_mnt[PATH_MAX] = "/sys/kernel/debug";
-char tracing_path[PATH_MAX] = "/sys/kernel/debug/tracing";
+static char tracing_path[PATH_MAX] = "/sys/kernel/debug/tracing";
char tracing_events_path[PATH_MAX] = "/sys/kernel/debug/tracing/events";
@@ -75,7 +75,7 @@ char *get_tracing_file(const char *name)
{
char *file;
- if (asprintf(&file, "%s/%s", tracing_path, name) < 0)
+ if (asprintf(&file, "%s/%s", tracing_path_mount(), name) < 0)
return NULL;
return file;
diff --git a/tools/lib/api/fs/tracing_path.h b/tools/lib/api/fs/tracing_path.h
index 0066f06cc381..1b65decedfc0 100644
--- a/tools/lib/api/fs/tracing_path.h
+++ b/tools/lib/api/fs/tracing_path.h
@@ -4,7 +4,6 @@
#include <linux/types.h>
-extern char tracing_path[];
extern char tracing_events_path[];
void tracing_path_set(const char *mountpoint);
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index cd6ea55d4b0c..d5a0878de816 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -238,7 +238,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
(*argc)--;
} else if (strstarts(cmd, CMD_DEBUGFS_DIR)) {
tracing_path_set(cmd + strlen(CMD_DEBUGFS_DIR));
- fprintf(stderr, "dir: %s\n", tracing_path);
+ fprintf(stderr, "dir: %s\n", tracing_path_mount());
if (envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--list-cmds")) {
@@ -463,9 +463,6 @@ int main(int argc, const char **argv)
return err;
set_buildid_dir(NULL);
- /* get debugfs/tracefs mount point from /proc/mounts */
- tracing_path_mount();
-
/*
* "perf-xxxx" is the same as "perf xxxx", but we obviously:
*
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 4ae1123c6794..b76088fadf3d 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -84,8 +84,7 @@ int open_trace_file(const char *trace_file, bool readwrite)
char buf[PATH_MAX];
int ret;
- ret = e_snprintf(buf, PATH_MAX, "%s/%s",
- tracing_path, trace_file);
+ ret = e_snprintf(buf, PATH_MAX, "%s/%s", tracing_path_mount(), trace_file);
if (ret >= 0) {
pr_debug("Opening %s write=%d\n", buf, readwrite);
if (readwrite && !probe_event_dry_run)
--
2.14.3
next prev parent reply other threads:[~2018-05-19 10:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-19 10:54 [GIT PULL 00/18] perf/core improvements and fixes Arnaldo Carvalho de Melo
2018-05-19 10:54 ` [PATCH 01/18] perf config: Call perf_config__init() lazily Arnaldo Carvalho de Melo
2018-05-19 10:54 ` [PATCH 02/18] tools lib api: The tracing_mnt variable doesn't need to be global Arnaldo Carvalho de Melo
2018-05-19 10:54 ` Arnaldo Carvalho de Melo [this message]
2018-05-19 10:54 ` [PATCH 04/18] tools lib api fs tracing_path: Introduce get/put_events_file() helpers Arnaldo Carvalho de Melo
2018-05-19 10:54 ` [PATCH 05/18] perf tools: Reuse the path to the tracepoint /events/ directory Arnaldo Carvalho de Melo
2018-05-19 10:54 ` [PATCH 06/18] perf parse-events: Use get/put_events_file() Arnaldo Carvalho de Melo
2018-05-19 10:54 ` [PATCH 07/18] tools lib api fs tracing_path: Introduce opendir() method Arnaldo Carvalho de Melo
2018-05-19 10:54 ` [PATCH 08/18] tools lib api fs tracing_path: Make tracing_events_path private Arnaldo Carvalho de Melo
2018-05-19 10:54 ` [PATCH 09/18] tools include compiler-gcc: Add __pure attribute helper Arnaldo Carvalho de Melo
2018-05-19 10:54 ` [PATCH 10/18] perf tools: Read the cache line size lazily Arnaldo Carvalho de Melo
2018-05-19 10:55 ` [PATCH 11/18] perf tools: No need to unconditionally read the max_stack sysctls Arnaldo Carvalho de Melo
2018-05-19 10:55 ` [PATCH 12/18] perf script: Show virtual addresses instead of offsets Arnaldo Carvalho de Melo
2018-05-19 10:55 ` [PATCH 13/18] perf script: Show symbol offsets by default Arnaldo Carvalho de Melo
2018-05-19 10:55 ` [PATCH 14/18] perf annotate: Record the min/max cycles Arnaldo Carvalho de Melo
2018-05-19 10:55 ` [PATCH 15/18] perf annotate: Create hotkey 'c' to show " Arnaldo Carvalho de Melo
2018-05-19 10:55 ` [PATCH 16/18] perf bpf: Fixup include and examples install messages Arnaldo Carvalho de Melo
2018-05-19 10:55 ` [PATCH 17/18] perf machine: Add machine__is() to identify machine arch Arnaldo Carvalho de Melo
2018-05-19 10:55 ` [PATCH 18/18] perf tools: Fix kernel_start for PTI on x86 Arnaldo Carvalho de Melo
2018-05-19 11:33 ` [GIT PULL 00/18] perf/core improvements and fixes Ingo Molnar
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=20180519105507.16450-4-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=dsahern@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=wangnan0@huawei.com \
--cc=williams@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).