Skip to contentSkip to conversation

perf tools: Cleanup filesystem api

PATCH In review Jiri Olsa 10 participants 72 messages Sep 2, 2015 – Oct 13, 2015 perf events

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

cover perf tools: Cleanup filesystem api

hi,
this patchset moves all filesystem we use under api/fs/fs.c framework and adds new tracing_path object to get tracing area (path).

It unifies the way we use debugfs/tracefs paths and removes some redundant code.

It's base for the tracepoint parsing error reporting I posted recently.

jirka

---
Jiri Olsa (15):
perf tools: Fix parse_events_add_pmu caller
perf tools: Remove mountpoint arg from perf_debugfs_mount perf tools: Move tracing_path stuff under same namespace perf tools: Move tracing_path interface into api/fs/tracing_path.c tools lib api: Move debugfs__strerror_open into tracing_path.c object tools lib api: Make tracing_path_strerror_open message generic tools lib api: Add STR and PATH_MAX macros to fs object tools lib api: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c tools lib api: Add debugfs into fs.c object
tools lib api: Add tracefs into fs.c object
tools lib api: Add mount support for fs
tools lib api: Add configured support for fs
tools lib api: Replace debugfs/tracefs objects interface with fs.c tools lib api: Remove debugfs, tracefs and findfs objects perf tools: Switch to tracing_path interface on appropriate places

 tools/lib/api/fs/Build                     |   4 +--
 tools/lib/api/fs/debugfs.c                 | 129 -----------------------------------------------------------------------------------
 tools/lib/api/fs/debugfs.h                 |  23 ---------------
 tools/lib/api/fs/findfs.c                  |  63 -----------------------------------------
 tools/lib/api/fs/findfs.h                  |  23 ---------------
 tools/lib/api/fs/fs.c                      | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 tools/lib/api/fs/fs.h                      |  26 ++++++++++++-----
 tools/lib/api/fs/tracefs.c                 |  78 --------------------------------------------------
 tools/lib/api/fs/tracefs.h                 |  21 --------------
 tools/lib/api/fs/tracing_path.c            | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h            |  16 +++++++++++
 tools/perf/builtin-kvm.c                   |   1 -
 tools/perf/builtin-probe.c                 |   1 -
 tools/perf/builtin-trace.c                 |   5 ++--
 tools/perf/perf.c                          |  12 ++++----
 tools/perf/tests/openat-syscall-all-cpus.c |  10 +++----
 tools/perf/tests/openat-syscall.c          |  10 +++----
 tools/perf/tests/parse-events.c            |  19 ++-----------
 tools/perf/util/evsel.c                    |   2 +-
 tools/perf/util/parse-events.c             |   2 +-
 tools/perf/util/parse-events.y             |   2 +-
 tools/perf/util/probe-event.c              |   5 ++--
 tools/perf/util/probe-file.c               |  15 ++--------
 tools/perf/util/trace-event-info.c         |   2 +-
 tools/perf/util/trace-event.c              |   1 +
 tools/perf/util/util.c                     |  70 ---------------------------------------------
 tools/perf/util/util.h                     |   9 +-----
 27 files changed, 310 insertions(+), 493 deletions(-)
 delete mode 100644 tools/lib/api/fs/debugfs.c
 delete mode 100644 tools/lib/api/fs/debugfs.h
 delete mode 100644 tools/lib/api/fs/findfs.c
 delete mode 100644 tools/lib/api/fs/findfs.h
 delete mode 100644 tools/lib/api/fs/tracefs.c
 delete mode 100644 tools/lib/api/fs/tracefs.h
 create mode 100644 tools/lib/api/fs/tracing_path.c
 create mode 100644 tools/lib/api/fs/tracing_path.h
author reviewer
#1 lore raw

PATCH 1/15 perf tools: Fix parse_events_add_pmu caller

Following commit changed parse_events_add_pmu interface:
36adec85a86f perf tools: Change parse_events_add_pmu interface

but forgot to change one caller. Because of lessen compilation rules for the bison parser, the compiler did not warn on that.

---
 tools/perf/util/parse-events.y | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/parse-events.y +1 -1
index 591905a02b92..9cd70819c795 100644
@@ -255,7 +255,7 @@ PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
 	list_add_tail(&term->list, head);
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_pmu(list, &data->idx, "cpu", head));
+	ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
 	parse_events__free_terms(head);
 	$$ = list;
 }
Signature · 1 line
2.4.3
#2 lore raw

Re: [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller

Em Wed, Sep 02, 2015 at 09:56:31AM +0200, Jiri Olsa escreveu:

Quoted 5 lines

Following commit changed parse_events_add_pmu interface:
36adec85a86f perf tools: Change parse_events_add_pmu interface

but forgot to change one caller. Because of lessen compilation rules for the bison parser, the compiler did not warn on that.

Humm, wonder what can be done to improve this situation... No ideas?

Applying to perf/urgent,

Thanks,

- Arnaldo

Quoted 21 lines
---
 tools/perf/util/parse-events.y | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/parse-events.y +1 -1
index 591905a02b92..9cd70819c795 100644
@@ -255,7 +255,7 @@ PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
 	list_add_tail(&term->list, head);
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_pmu(list, &data->idx, "cpu", head));
+	ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
 	parse_events__free_terms(head);
 	$$ = list;
 }
Signature · 1 line
2.4.3
#3 lore raw

Re: [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller

Quoted 8 lines · Arnaldo Carvalho de Melo

Em Wed, Sep 02, 2015 at 09:56:31AM +0200, Jiri Olsa escreveu:

Quoted 5 lines

Following commit changed parse_events_add_pmu interface:
36adec85a86f perf tools: Change parse_events_add_pmu interface

but forgot to change one caller. Because of lessen compilation rules for the bison parser, the compiler did not warn on that.

Humm, wonder what can be done to improve this situation... No ideas?

not really.. :-\ it's generated code, that will fail to compile or spit other loads of warnings if we enable them

moving most of the code out of parse-event.y to other objects helps, but thats pretty much what we do now

Quoted 2 lines

Applying to perf/urgent,

thanks,
jirka

#4 lore raw

[tip:perf/urgent] perf tools: Fix parse_events_add_pmu caller

In reply to Jiri Olsa
perf tools: Fix parse_events_add_pmu caller
Commit-ID:  5ad4da4302712fba10624d28cb6c269fee592b69
Gitweb:     http://git.kernel.org/tip/5ad4da4302712fba10624d28cb6c269fee592b69
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:31 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 2 Sep 2015 09:58:57 -0300

perf tools: Fix parse_events_add_pmu caller

Following commit changed parse_events_add_pmu interface:
36adec85a86f perf tools: Change parse_events_add_pmu interface

but forgot to change one caller. Because of lessen compilation rules for the bison parser, the compiler did not warn on that.

Cc Raphael Beamonte <[email protected]>
Cc David Ahern <[email protected]>
Cc Matt Fleming <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Steven Rostedt <[email protected]>
Fixes 36adec85a86f ("perf tools: Change parse_events_add_pmu interface")
---
 tools/perf/util/parse-events.y | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/parse-events.y +1 -1
index 591905a..9cd7081 100644
@@ -255,7 +255,7 @@ PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
 	list_add_tail(&term->list, head);
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_pmu(list, &data->idx, "cpu", head));
+	ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
 	parse_events__free_terms(head);
 	$$ = list;
 }
author reviewer
#5 lore raw

PATCH 2/15 perf tools: Remove mountpoint arg from perf_debugfs_mount

In reply to Jiri Olsa

It's not used by any caller. We either detect the mountpoint or use hardcoded one.

---
 tools/perf/perf.c      |  2 +-
 tools/perf/util/util.c | 14 +++++++-------
 tools/perf/util/util.h |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
tools/perf/perf.c +1 -1
index 07dbff5c0e60..f500a4b40722 100644
@@ -518,7 +518,7 @@ int main(int argc, const char **argv)
 	if (!cmd)
 		cmd = "perf-help";
 	/* get debugfs mount point from /proc/mounts */
-	perf_debugfs_mount(NULL);
+	perf_debugfs_mount();
 	/*
 	 * "perf-xxxx" is the same as "perf xxxx", but we obviously:
 	 *
tools/perf/util/util.c +7 -7
index 7acafb3c5592..74f71f8afcc2 100644
@@ -398,11 +398,11 @@ static void set_tracing_events_path(const char *tracing, const char *mountpoint)
 		 mountpoint, tracing, "events");
 }
 
-static const char *__perf_tracefs_mount(const char *mountpoint)
+static const char *__perf_tracefs_mount(void)
 {
 	const char *mnt;
 
-	mnt = tracefs_mount(mountpoint);
+	mnt = tracefs_mount(NULL);
 	if (!mnt)
 		return NULL;
 
@@ -411,11 +411,11 @@ static const char *__perf_tracefs_mount(const char *mountpoint)
 	return mnt;
 }
 
-static const char *__perf_debugfs_mount(const char *mountpoint)
+static const char *__perf_debugfs_mount(void)
 {
 	const char *mnt;
 
-	mnt = debugfs_mount(mountpoint);
+	mnt = debugfs_mount(NULL);
 	if (!mnt)
 		return NULL;
 
@@ -424,15 +424,15 @@ static const char *__perf_debugfs_mount(const char *mountpoint)
 	return mnt;
 }
 
-const char *perf_debugfs_mount(const char *mountpoint)
+const char *perf_debugfs_mount(void)
 {
 	const char *mnt;
 
-	mnt = __perf_tracefs_mount(mountpoint);
+	mnt = __perf_tracefs_mount();
 	if (mnt)
 		return mnt;
 
-	mnt = __perf_debugfs_mount(mountpoint);
+	mnt = __perf_debugfs_mount();
 
 	return mnt;
 }
tools/perf/util/util.h +1 -1
index 291be1d84bc3..184d40048faa 100644
@@ -86,7 +86,7 @@ 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 *perf_debugfs_mount(void);
 char *get_tracing_file(const char *name);
 void put_tracing_file(char *file);
 
Signature · 1 line
2.4.3
#6 lore raw

[tip:perf/core] perf tools: Remove mountpoint arg from perf_debugfs_mount

perf tools: Remove mountpoint arg from perf_debugfs_mount
Commit-ID:  f6a09af7de3b39b1e4fcff7374871f834498b7f0
Gitweb:     http://git.kernel.org/tip/f6a09af7de3b39b1e4fcff7374871f834498b7f0
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:32 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 2 Sep 2015 16:30:47 -0300

perf tools: Remove mountpoint arg from perf_debugfs_mount

It's not used by any caller. We either detect the mountpoint or use hardcoded one.

---
 tools/perf/perf.c      |  2 +-
 tools/perf/util/util.c | 14 +++++++-------
 tools/perf/util/util.h |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
tools/perf/perf.c +1 -1
index 07dbff5..f500a4b 100644
@@ -518,7 +518,7 @@ int main(int argc, const char **argv)
 	if (!cmd)
 		cmd = "perf-help";
 	/* get debugfs mount point from /proc/mounts */
-	perf_debugfs_mount(NULL);
+	perf_debugfs_mount();
 	/*
 	 * "perf-xxxx" is the same as "perf xxxx", but we obviously:
 	 *
tools/perf/util/util.c +7 -7
index 7acafb3..74f71f8 100644
@@ -398,11 +398,11 @@ static void set_tracing_events_path(const char *tracing, const char *mountpoint)
 		 mountpoint, tracing, "events");
 }
 
-static const char *__perf_tracefs_mount(const char *mountpoint)
+static const char *__perf_tracefs_mount(void)
 {
 	const char *mnt;
 
-	mnt = tracefs_mount(mountpoint);
+	mnt = tracefs_mount(NULL);
 	if (!mnt)
 		return NULL;
 
@@ -411,11 +411,11 @@ static const char *__perf_tracefs_mount(const char *mountpoint)
 	return mnt;
 }
 
-static const char *__perf_debugfs_mount(const char *mountpoint)
+static const char *__perf_debugfs_mount(void)
 {
 	const char *mnt;
 
-	mnt = debugfs_mount(mountpoint);
+	mnt = debugfs_mount(NULL);
 	if (!mnt)
 		return NULL;
 
@@ -424,15 +424,15 @@ static const char *__perf_debugfs_mount(const char *mountpoint)
 	return mnt;
 }
 
-const char *perf_debugfs_mount(const char *mountpoint)
+const char *perf_debugfs_mount(void)
 {
 	const char *mnt;
 
-	mnt = __perf_tracefs_mount(mountpoint);
+	mnt = __perf_tracefs_mount();
 	if (mnt)
 		return mnt;
 
-	mnt = __perf_debugfs_mount(mountpoint);
+	mnt = __perf_debugfs_mount();
 
 	return mnt;
 }
tools/perf/util/util.h +1 -1
index 09c1a8b..48ec232 100644
@@ -86,7 +86,7 @@ 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 *perf_debugfs_mount(void);
 char *get_tracing_file(const char *name);
 void put_tracing_file(char *file);
 
author reviewer
#7 lore raw

PATCH 3/15 perf tools: Move tracing_path stuff under same namespace

In reply to Jiri Olsa

Renaming all functions touching tracing_path under same namespace. New interface is:

char tracing_path[];
- tracing mount path

char tracing_events_path[];
- tracing mount/events path

void tracing_path_set(const char *mountpoint);
- setting directly tracing_path(_events), used by --debugfs-dir option

const char *tracing_path_mount(void);
- initial setup of tracing_(events)_path, called from perf.c mounts debugfs/tracefs if needed and possible

  char *get_tracing_file(const char *name);
  void put_tracing_file(char *file);
  - get/put tracing file path
---
 tools/perf/perf.c      | 10 ++++++----
 tools/perf/util/util.c | 20 ++++++++++----------
 tools/perf/util/util.h |  4 ++--
 3 files changed, 18 insertions(+), 16 deletions(-)
tools/perf/perf.c +6 -4
index f500a4b40722..0e99cd1de9dd 100644
@@ -214,7 +214,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				fprintf(stderr, "No directory given for --debugfs-dir.\n");
 				usage(perf_usage_string);
 			}
-			perf_debugfs_set_path((*argv)[1]);
+			tracing_path_set((*argv)[1]);
 			if (envchanged)
 				*envchanged = 1;
 			(*argv)++;
@@ -230,7 +230,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			(*argv)++;
 			(*argc)--;
 		} else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) {
-			perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR));
+			tracing_path_set(cmd + strlen(CMD_DEBUGFS_DIR));
 			fprintf(stderr, "dir: %s\n", tracing_path);
 			if (envchanged)
 				*envchanged = 1;
@@ -517,8 +517,10 @@ int main(int argc, const char **argv)
 	cmd = perf_extract_argv0_path(argv[0]);
 	if (!cmd)
 		cmd = "perf-help";
-	/* get debugfs mount point from /proc/mounts */
-	perf_debugfs_mount();
+
+	/* get debugfs/tracefs mount point from /proc/mounts */
+	tracing_path_mount();
+
 	/*
 	 * "perf-xxxx" is the same as "perf xxxx", but we obviously:
 	 *
tools/perf/util/util.c +10 -10
index 74f71f8afcc2..b959f783f6cd 100644
@@ -390,7 +390,7 @@ void set_term_quiet_input(struct termios *old)
 	tcsetattr(0, TCSANOW, &tc);
 }
 
-static void set_tracing_events_path(const char *tracing, const char *mountpoint)
+static void __tracing_path_set(const char *tracing, const char *mountpoint)
 {
 	snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
 		 mountpoint, tracing);
@@ -398,7 +398,7 @@ static void set_tracing_events_path(const char *tracing, const char *mountpoint)
 		 mountpoint, tracing, "events");
 }
 
-static const char *__perf_tracefs_mount(void)
+static const char *tracing_path_tracefs_mount(void)
 {
 	const char *mnt;
 
@@ -406,12 +406,12 @@ static const char *__perf_tracefs_mount(void)
 	if (!mnt)
 		return NULL;
 
-	set_tracing_events_path("", mnt);
+	__tracing_path_set("", mnt);
 
 	return mnt;
 }
 
-static const char *__perf_debugfs_mount(void)
+static const char *tracing_path_debugfs_mount(void)
 {
 	const char *mnt;
 
@@ -419,27 +419,27 @@ static const char *__perf_debugfs_mount(void)
 	if (!mnt)
 		return NULL;
 
-	set_tracing_events_path("tracing/", mnt);
+	__tracing_path_set("tracing/", mnt);
 
 	return mnt;
 }
 
-const char *perf_debugfs_mount(void)
+const char *tracing_path_mount(void)
 {
 	const char *mnt;
 
-	mnt = __perf_tracefs_mount();
+	mnt = tracing_path_tracefs_mount();
 	if (mnt)
 		return mnt;
 
-	mnt = __perf_debugfs_mount();
+	mnt = tracing_path_debugfs_mount();
 
 	return mnt;
 }
 
-void perf_debugfs_set_path(const char *mntpt)
+void tracing_path_set(const char *mntpt)
 {
-	set_tracing_events_path("tracing/", mntpt);
+	__tracing_path_set("tracing/", mntpt);
 }
 
 char *get_tracing_file(const char *name)
tools/perf/util/util.h +2 -2
index 184d40048faa..230c4124bfa7 100644
@@ -85,8 +85,8 @@ 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(void);
+extern void tracing_path_set(const char *mountpoint);
+const char *tracing_path_mount(void);
 char *get_tracing_file(const char *name);
 void put_tracing_file(char *file);
 
Signature · 1 line
2.4.3
#8 lore raw

[tip:perf/core] perf tools: Move tracing_path stuff under same namespace

perf tools: Move tracing_path stuff under same namespace
Commit-ID:  65d4b265103a3cb2f0993c946815157a38797421
Gitweb:     http://git.kernel.org/tip/65d4b265103a3cb2f0993c946815157a38797421
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:33 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 2 Sep 2015 16:30:47 -0300

perf tools: Move tracing_path stuff under same namespace

Renaming all functions touching tracing_path under same namespace. New interface is:

char tracing_path[];
- tracing mount path

char tracing_events_path[];
- tracing mount/events path

void tracing_path_set(const char *mountpoint);
- setting directly tracing_path(_events), used by --debugfs-dir option

const char *tracing_path_mount(void);
- initial setup of tracing_(events)_path, called from perf.c mounts debugfs/tracefs if needed and possible

  char *get_tracing_file(const char *name);
  void put_tracing_file(char *file);
  - get/put tracing file path
---
 tools/perf/perf.c      | 10 ++++++----
 tools/perf/util/util.c | 20 ++++++++++----------
 tools/perf/util/util.h |  4 ++--
 3 files changed, 18 insertions(+), 16 deletions(-)
tools/perf/perf.c +6 -4
index f500a4b..0e99cd1 100644
@@ -214,7 +214,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				fprintf(stderr, "No directory given for --debugfs-dir.\n");
 				usage(perf_usage_string);
 			}
-			perf_debugfs_set_path((*argv)[1]);
+			tracing_path_set((*argv)[1]);
 			if (envchanged)
 				*envchanged = 1;
 			(*argv)++;
@@ -230,7 +230,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			(*argv)++;
 			(*argc)--;
 		} else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) {
-			perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR));
+			tracing_path_set(cmd + strlen(CMD_DEBUGFS_DIR));
 			fprintf(stderr, "dir: %s\n", tracing_path);
 			if (envchanged)
 				*envchanged = 1;
@@ -517,8 +517,10 @@ int main(int argc, const char **argv)
 	cmd = perf_extract_argv0_path(argv[0]);
 	if (!cmd)
 		cmd = "perf-help";
-	/* get debugfs mount point from /proc/mounts */
-	perf_debugfs_mount();
+
+	/* get debugfs/tracefs mount point from /proc/mounts */
+	tracing_path_mount();
+
 	/*
 	 * "perf-xxxx" is the same as "perf xxxx", but we obviously:
 	 *
tools/perf/util/util.c +10 -10
index 74f71f8..b959f78 100644
@@ -390,7 +390,7 @@ void set_term_quiet_input(struct termios *old)
 	tcsetattr(0, TCSANOW, &tc);
 }
 
-static void set_tracing_events_path(const char *tracing, const char *mountpoint)
+static void __tracing_path_set(const char *tracing, const char *mountpoint)
 {
 	snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
 		 mountpoint, tracing);
@@ -398,7 +398,7 @@ static void set_tracing_events_path(const char *tracing, const char *mountpoint)
 		 mountpoint, tracing, "events");
 }
 
-static const char *__perf_tracefs_mount(void)
+static const char *tracing_path_tracefs_mount(void)
 {
 	const char *mnt;
 
@@ -406,12 +406,12 @@ static const char *__perf_tracefs_mount(void)
 	if (!mnt)
 		return NULL;
 
-	set_tracing_events_path("", mnt);
+	__tracing_path_set("", mnt);
 
 	return mnt;
 }
 
-static const char *__perf_debugfs_mount(void)
+static const char *tracing_path_debugfs_mount(void)
 {
 	const char *mnt;
 
@@ -419,27 +419,27 @@ static const char *__perf_debugfs_mount(void)
 	if (!mnt)
 		return NULL;
 
-	set_tracing_events_path("tracing/", mnt);
+	__tracing_path_set("tracing/", mnt);
 
 	return mnt;
 }
 
-const char *perf_debugfs_mount(void)
+const char *tracing_path_mount(void)
 {
 	const char *mnt;
 
-	mnt = __perf_tracefs_mount();
+	mnt = tracing_path_tracefs_mount();
 	if (mnt)
 		return mnt;
 
-	mnt = __perf_debugfs_mount();
+	mnt = tracing_path_debugfs_mount();
 
 	return mnt;
 }
 
-void perf_debugfs_set_path(const char *mntpt)
+void tracing_path_set(const char *mntpt)
 {
-	set_tracing_events_path("tracing/", mntpt);
+	__tracing_path_set("tracing/", mntpt);
 }
 
 char *get_tracing_file(const char *name)
tools/perf/util/util.h +2 -2
index 48ec232..bbf8a93 100644
@@ -85,8 +85,8 @@ 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(void);
+extern void tracing_path_set(const char *mountpoint);
+const char *tracing_path_mount(void);
 char *get_tracing_file(const char *name);
 void put_tracing_file(char *file);
 
author reviewer
#9 lore raw

PATCH 4/15 perf tools: Move tracing_path interface into api/fs/tracing_path.c

In reply to Jiri Olsa

Moving tracing_path interface into api/fs/tracing_path.c out of util.c. It seems generic enough to be used by others, and I couldn't think of better place.

---
 tools/lib/api/fs/Build             |  1 +
 tools/lib/api/fs/tracing_path.c    | 83 ++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h    | 13 ++++++
 tools/perf/perf.c                  |  2 +-
 tools/perf/util/parse-events.c     |  2 +-
 tools/perf/util/trace-event-info.c |  2 +-
 tools/perf/util/trace-event.c      |  1 +
 tools/perf/util/util.c             | 70 --------------------------------
 tools/perf/util/util.h             |  6 ---
 9 files changed, 101 insertions(+), 79 deletions(-)
 create mode 100644 tools/lib/api/fs/tracing_path.c
 create mode 100644 tools/lib/api/fs/tracing_path.h
tools/lib/api/fs/Build +1 -0
index 6de5a4f0b501..fa726f679b29 100644
@@ -1,4 +1,5 @@
 libapi-y += fs.o
+libapi-y += tracing_path.o
 libapi-y += debugfs.o
 libapi-y += findfs.o
 libapi-y += tracefs.o
tools/lib/api/fs/tracing_path.c new file +83 -0

83 lines not on this page · raw message

tools/lib/api/fs/tracing_path.h new file +13 -0
new file mode 100644
index 000000000000..b132dc599fe5
@@ -0,0 +1,13 @@
+#ifndef __API_FS_TRACING_PATH_H
+#define __API_FS_TRACING_PATH_H
+
+extern char tracing_path[];
+extern char tracing_events_path[];
+
+void tracing_path_set(const char *mountpoint);
+const char *tracing_path_mount(void);
+
+char *get_tracing_file(const char *name);
+void put_tracing_file(char *file);
+
+#endif /* __API_FS_TRACING_PATH_H */
tools/perf/perf.c +1 -1
index 0e99cd1de9dd..f2fc019b3671 100644
@@ -15,7 +15,7 @@
 #include "util/parse-events.h"
 #include "util/parse-options.h"
 #include "util/debug.h"
-#include <api/fs/debugfs.h>
+#include <api/fs/tracing_path.h>
 #include <pthread.h>
 
 const char perf_usage_string[] =
tools/perf/util/parse-events.c +1 -1
index d826e6f515db..3840176642f8 100644
@@ -11,7 +11,7 @@
 #include "cache.h"
 #include "header.h"
 #include "debug.h"
-#include <api/fs/debugfs.h>
+#include <api/fs/tracing_path.h>
 #include "parse-events-bison.h"
 #define YY_EXTRA_TYPE int
 #include "parse-events-flex.h"
tools/perf/util/trace-event-info.c +1 -1
index 22245986e59e..d995743cb673 100644
@@ -38,7 +38,7 @@
 
 #include "../perf.h"
 #include "trace-event.h"
-#include <api/fs/debugfs.h>
+#include <api/fs/tracing_path.h>
 #include "evsel.h"
 #include "debug.h"
 
tools/perf/util/trace-event.c +1 -0
index b90e646c7a91..2f4996ab313d 100644
@@ -8,6 +8,7 @@
 #include <fcntl.h>
 #include <linux/kernel.h>
 #include <traceevent/event-parse.h>
+#include <api/fs/tracing_path.h>
 #include "trace-event.h"
 #include "machine.h"
 #include "util.h"
tools/perf/util/util.c +0 -70

82 lines not on this page · raw message

tools/perf/util/util.h +0 -6
index 230c4124bfa7..f9a9717d2aff 100644
@@ -83,12 +83,6 @@
 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 tracing_path_set(const char *mountpoint);
-const char *tracing_path_mount(void);
-char *get_tracing_file(const char *name);
-void put_tracing_file(char *file);
 
 /* On most systems <limits.h> would have given us this, but
  * not on some systems (e.g. GNU/Hurd).
Signature · 1 line
2.4.3
Reviewed-by on v1 4/15
#10 lore raw

Re: [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c

Quoted 6 lines · Jiri Olsa

Moving tracing_path interface into api/fs/tracing_path.c out of util.c. It seems generic enough to be used by others, and I couldn't think of better place.

Quoted 13 lines
---
 tools/lib/api/fs/Build             |  1 +
 tools/lib/api/fs/tracing_path.c    | 83 ++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h    | 13 ++++++
 tools/perf/perf.c                  |  2 +-
 tools/perf/util/parse-events.c     |  2 +-
 tools/perf/util/trace-event-info.c |  2 +-
 tools/perf/util/trace-event.c      |  1 +
 tools/perf/util/util.c             | 70 --------------------------------
 tools/perf/util/util.h             |  6 ---
 9 files changed, 101 insertions(+), 79 deletions(-)
 create mode 100644 tools/lib/api/fs/tracing_path.c
 create mode 100644 tools/lib/api/fs/tracing_path.h
Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
Reviewed-by
#11 lore raw

Re: [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c

2015-09-04 7:35 GMT-04:00 Matt Fleming <[email protected]>:

Quoted 21 lines · Jiri Olsa
Quoted 6 lines

Moving tracing_path interface into api/fs/tracing_path.c out of util.c. It seems generic enough to be used by others, and I couldn't think of better place.

Quoted 13 lines
---
 tools/lib/api/fs/Build             |  1 +
 tools/lib/api/fs/tracing_path.c    | 83 ++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h    | 13 ++++++
 tools/perf/perf.c                  |  2 +-
 tools/perf/util/parse-events.c     |  2 +-
 tools/perf/util/trace-event-info.c |  2 +-
 tools/perf/util/trace-event.c      |  1 +
 tools/perf/util/util.c             | 70 --------------------------------
 tools/perf/util/util.h             |  6 ---
 9 files changed, 101 insertions(+), 79 deletions(-)
 create mode 100644 tools/lib/api/fs/tracing_path.c
 create mode 100644 tools/lib/api/fs/tracing_path.h
Quoted 4 lines

--
Matt Fleming, Intel Open Source Technology Center

I can get behind that too.

#12 lore raw

[tip:perf/core] tools lib api fs: Move tracing_path interface into api/fs/tracing_path.c

In reply to Jiri Olsa
tools lib api fs: Move tracing_path interface into api/fs/tracing_path.c
Commit-ID:  592d5a6ba86a31681fa5e20a63a145b0a3b53c8a
Gitweb:     http://git.kernel.org/tip/592d5a6ba86a31681fa5e20a63a145b0a3b53c8a
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:34 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Sep 2015 12:00:45 -0300

tools lib api fs: Move tracing_path interface into api/fs/tracing_path.c

Moving tracing_path interface into api/fs/tracing_path.c out of util.c. It seems generic enough to be used by others, and I couldn't think of better place.

---
 tools/lib/api/fs/Build             |  1 +
 tools/lib/api/fs/tracing_path.c    | 83 ++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h    | 13 ++++++
 tools/perf/perf.c                  |  2 +-
 tools/perf/util/parse-events.c     |  2 +-
 tools/perf/util/trace-event-info.c |  2 +-
 tools/perf/util/trace-event.c      |  1 +
 tools/perf/util/util.c             | 70 --------------------------------
 tools/perf/util/util.h             |  6 ---
 9 files changed, 101 insertions(+), 79 deletions(-)
tools/lib/api/fs/Build +1 -0
index 6de5a4f..fa726f6 100644
@@ -1,4 +1,5 @@
 libapi-y += fs.o
+libapi-y += tracing_path.o
 libapi-y += debugfs.o
 libapi-y += findfs.o
 libapi-y += tracefs.o
tools/lib/api/fs/tracing_path.c new file +83 -0

83 lines not on this page · raw message

tools/lib/api/fs/tracing_path.h new file +13 -0
new file mode 100644
index 0000000..b132dc5
@@ -0,0 +1,13 @@
+#ifndef __API_FS_TRACING_PATH_H
+#define __API_FS_TRACING_PATH_H
+
+extern char tracing_path[];
+extern char tracing_events_path[];
+
+void tracing_path_set(const char *mountpoint);
+const char *tracing_path_mount(void);
+
+char *get_tracing_file(const char *name);
+void put_tracing_file(char *file);
+
+#endif /* __API_FS_TRACING_PATH_H */
tools/perf/perf.c +1 -1
index 0e99cd1..f2fc019 100644
@@ -15,7 +15,7 @@
 #include "util/parse-events.h"
 #include "util/parse-options.h"
 #include "util/debug.h"
-#include <api/fs/debugfs.h>
+#include <api/fs/tracing_path.h>
 #include <pthread.h>
 
 const char perf_usage_string[] =
tools/perf/util/parse-events.c +1 -1
index d826e6f..3840176 100644
@@ -11,7 +11,7 @@
 #include "cache.h"
 #include "header.h"
 #include "debug.h"
-#include <api/fs/debugfs.h>
+#include <api/fs/tracing_path.h>
 #include "parse-events-bison.h"
 #define YY_EXTRA_TYPE int
 #include "parse-events-flex.h"
tools/perf/util/trace-event-info.c +1 -1
index 2224598..d995743 100644
@@ -38,7 +38,7 @@
 
 #include "../perf.h"
 #include "trace-event.h"
-#include <api/fs/debugfs.h>
+#include <api/fs/tracing_path.h>
 #include "evsel.h"
 #include "debug.h"
 
tools/perf/util/trace-event.c +1 -0
index b90e646..2f4996a 100644
@@ -8,6 +8,7 @@
 #include <fcntl.h>
 #include <linux/kernel.h>
 #include <traceevent/event-parse.h>
+#include <api/fs/tracing_path.h>
 #include "trace-event.h"
 #include "machine.h"
 #include "util.h"
tools/perf/util/util.c +0 -70

82 lines not on this page · raw message

tools/perf/util/util.h +0 -6
index bbf8a93..495b99c 100644
@@ -83,12 +83,6 @@
 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 tracing_path_set(const char *mountpoint);
-const char *tracing_path_mount(void);
-char *get_tracing_file(const char *name);
-void put_tracing_file(char *file);
 
 /* On most systems <limits.h> would have given us this, but
  * not on some systems (e.g. GNU/Hurd).
author reviewer
#13 lore raw

PATCH 5/15 tools lib api: Move debugfs__strerror_open into tracing_path.c object

In reply to Jiri Olsa

Moving debugfs__strerror_open out of api/fs/debugfs.c, because it's not debugfs specific. It'll be changed to consider tracefs mount as well in following patches.

Renaming it into tracing_path__strerror_open_tp to fit into the namespace. No functional change is intended.

---
 tools/lib/api/fs/debugfs.c      | 52 ---------------------------------------
 tools/lib/api/fs/tracing_path.c | 54 +++++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h |  3 +++
 tools/perf/builtin-trace.c      |  5 ++--
 4 files changed, 60 insertions(+), 54 deletions(-)
tools/lib/api/fs/debugfs.c +0 -52
index eb7cf4d18f8a..c707cfb32782 100644
@@ -75,55 +75,3 @@ char *debugfs_mount(const char *mountpoint)
 out:
 	return debugfs_mountpoint;
 }
-
-int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename)
-{
-	char sbuf[128];
-
-	switch (err) {
-	case ENOENT:
-		if (debugfs_found) {
-			snprintf(buf, size,
-				 "Error:\tFile %s/%s not found.\n"
-				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 debugfs_mountpoint, filename);
-			break;
-		}
-		snprintf(buf, size, "%s",
-			 "Error:\tUnable to find debugfs\n"
-			 "Hint:\tWas your kernel compiled with debugfs support?\n"
-			 "Hint:\tIs the debugfs filesystem mounted?\n"
-			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
-		break;
-	case EACCES: {
-		const char *mountpoint = debugfs_mountpoint;
-
-		if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
-			const char *tracefs_mntpoint = tracefs_find_mountpoint();
-
-			if (tracefs_mntpoint)
-				mountpoint = tracefs_mntpoint;
-		}
-
-		snprintf(buf, size,
-			 "Error:\tNo permissions to read %s/%s\n"
-			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
-			 debugfs_mountpoint, filename, mountpoint);
-	}
-		break;
-	default:
-		snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
-		break;
-	}
-
-	return 0;
-}
-
-int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
-{
-	char path[PATH_MAX];
-
-	snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*");
-
-	return debugfs__strerror_open(err, buf, size, path);
-}
tools/lib/api/fs/tracing_path.c +54 -0

63 lines not on this page · raw message

tools/lib/api/fs/tracing_path.h +3 -0
index b132dc599fe5..3f233ac70b6f 100644
@@ -1,6 +1,8 @@
 #ifndef __API_FS_TRACING_PATH_H
 #define __API_FS_TRACING_PATH_H
 
+#include <linux/types.h>
+
 extern char tracing_path[];
 extern char tracing_events_path[];
 
@@ -10,4 +12,5 @@ const char *tracing_path_mount(void);
 char *get_tracing_file(const char *name);
 void put_tracing_file(char *file);
 
+int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);
 #endif /* __API_FS_TRACING_PATH_H */
tools/perf/builtin-trace.c +3 -2
index 4e3abba03062..215653274102 100644
@@ -17,6 +17,7 @@
  */
 
 #include <traceevent/event-parse.h>
+#include <api/fs/tracing_path.h>
 #include "builtin.h"
 #include "util/color.h"
 #include "util/debug.h"
@@ -2686,11 +2687,11 @@ out_delete_evlist:
 	char errbuf[BUFSIZ];
 
 out_error_sched_stat_runtime:
-	debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
+	tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
 	goto out_error;
 
 out_error_raw_syscalls:
-	debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "raw_syscalls", "sys_(enter|exit)");
+	tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "raw_syscalls", "sys_(enter|exit)");
 	goto out_error;
 
 out_error_mmap:
Signature · 1 line
2.4.3
#14 lore raw

Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object

Em Wed, Sep 02, 2015 at 09:56:35AM +0200, Jiri Olsa escreveu:

Quoted 6 lines

Moving debugfs__strerror_open out of api/fs/debugfs.c, because it's not debugfs specific. It'll be changed to consider tracefs mount as well in following patches.

Renaming it into tracing_path__strerror_open_tp to fit into the namespace. No functional change is intended.

Humm, here I think that "_path" may look excessive... But tracing_path__ better than debugfs__, so its progress, applying, if we get a better name, we can change this later.

- Arnaldo

Quoted 185 lines
---
 tools/lib/api/fs/debugfs.c      | 52 ---------------------------------------
 tools/lib/api/fs/tracing_path.c | 54 +++++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h |  3 +++
 tools/perf/builtin-trace.c      |  5 ++--
 4 files changed, 60 insertions(+), 54 deletions(-)
tools/lib/api/fs/debugfs.c +0 -52
index eb7cf4d18f8a..c707cfb32782 100644
@@ -75,55 +75,3 @@ char *debugfs_mount(const char *mountpoint)
 out:
 	return debugfs_mountpoint;
 }
-
-int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename)
-{
-	char sbuf[128];
-
-	switch (err) {
-	case ENOENT:
-		if (debugfs_found) {
-			snprintf(buf, size,
-				 "Error:\tFile %s/%s not found.\n"
-				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 debugfs_mountpoint, filename);
-			break;
-		}
-		snprintf(buf, size, "%s",
-			 "Error:\tUnable to find debugfs\n"
-			 "Hint:\tWas your kernel compiled with debugfs support?\n"
-			 "Hint:\tIs the debugfs filesystem mounted?\n"
-			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
-		break;
-	case EACCES: {
-		const char *mountpoint = debugfs_mountpoint;
-
-		if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
-			const char *tracefs_mntpoint = tracefs_find_mountpoint();
-
-			if (tracefs_mntpoint)
-				mountpoint = tracefs_mntpoint;
-		}
-
-		snprintf(buf, size,
-			 "Error:\tNo permissions to read %s/%s\n"
-			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
-			 debugfs_mountpoint, filename, mountpoint);
-	}
-		break;
-	default:
-		snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
-		break;
-	}
-
-	return 0;
-}
-
-int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
-{
-	char path[PATH_MAX];
-
-	snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*");
-
-	return debugfs__strerror_open(err, buf, size, path);
-}
tools/lib/api/fs/tracing_path.c +54 -0
index 1fd6e1f99234..3b3e4f5fc50b 100644
@@ -5,6 +5,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
+#include <unistd.h>
 #include "debugfs.h"
 #include "tracefs.h"
 
@@ -81,3 +83,55 @@ void put_tracing_file(char *file)
 {
 	free(file);
 }
+
+static int strerror_open(int err, char *buf, size_t size, const char *filename)
+{
+	char sbuf[128];
+
+	switch (err) {
+	case ENOENT:
+		if (debugfs_configured()) {
+			snprintf(buf, size,
+				 "Error:\tFile %s/%s not found.\n"
+				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
+				 debugfs_mountpoint, filename);
+			break;
+		}
+		snprintf(buf, size, "%s",
+			 "Error:\tUnable to find debugfs\n"
+			 "Hint:\tWas your kernel compiled with debugfs support?\n"
+			 "Hint:\tIs the debugfs filesystem mounted?\n"
+			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
+		break;
+	case EACCES: {
+		const char *mountpoint = debugfs_mountpoint;
+
+		if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
+			const char *tracefs_mntpoint = tracefs_find_mountpoint();
+
+			if (tracefs_mntpoint)
+				mountpoint = tracefs_mntpoint;
+		}
+
+		snprintf(buf, size,
+			 "Error:\tNo permissions to read %s/%s\n"
+			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
+			 debugfs_mountpoint, filename, mountpoint);
+	}
+		break;
+	default:
+		snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
+		break;
+	}
+
+	return 0;
+}
+
+int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
+{
+	char path[PATH_MAX];
+
+	snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*");
+
+	return strerror_open(err, buf, size, path);
+}
tools/lib/api/fs/tracing_path.h +3 -0
index b132dc599fe5..3f233ac70b6f 100644
@@ -1,6 +1,8 @@
 #ifndef __API_FS_TRACING_PATH_H
 #define __API_FS_TRACING_PATH_H
 
+#include <linux/types.h>
+
 extern char tracing_path[];
 extern char tracing_events_path[];
 
@@ -10,4 +12,5 @@ const char *tracing_path_mount(void);
 char *get_tracing_file(const char *name);
 void put_tracing_file(char *file);
 
+int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);
 #endif /* __API_FS_TRACING_PATH_H */
tools/perf/builtin-trace.c +3 -2
index 4e3abba03062..215653274102 100644
@@ -17,6 +17,7 @@
  */
 
 #include <traceevent/event-parse.h>
+#include <api/fs/tracing_path.h>
 #include "builtin.h"
 #include "util/color.h"
 #include "util/debug.h"
@@ -2686,11 +2687,11 @@ out_delete_evlist:
 	char errbuf[BUFSIZ];
 
 out_error_sched_stat_runtime:
-	debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
+	tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
 	goto out_error;
 
 out_error_raw_syscalls:
-	debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "raw_syscalls", "sys_(enter|exit)");
+	tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "raw_syscalls", "sys_(enter|exit)");
 	goto out_error;
 
 out_error_mmap:
Signature · 1 line
2.4.3
Reviewed-by on v1 5/15
#15 lore raw

Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object

In reply to Jiri Olsa
Quoted 7 lines · Jiri Olsa

Moving debugfs__strerror_open out of api/fs/debugfs.c, because it's not debugfs specific. It'll be changed to consider tracefs mount as well in following patches.

Renaming it into tracing_path__strerror_open_tp to fit into the namespace. No functional change is intended.

Quoted 8 lines
---
 tools/lib/api/fs/debugfs.c      | 52 ---------------------------------------
 tools/lib/api/fs/tracing_path.c | 54 +++++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h |  3 +++
 tools/perf/builtin-trace.c      |  5 ++--
 4 files changed, 60 insertions(+), 54 deletions(-)
Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#16 lore raw

Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object

In reply to Jiri Olsa

2015-09-02 9:12 GMT-04:00 Arnaldo Carvalho de Melo <[email protected]>:

Quoted 6 lines

Em Wed, Sep 02, 2015 at 09:56:35AM +0200, Jiri Olsa escreveu:
Humm, here I think that "_path" may look excessive... But tracing_path__ better than debugfs__, so its progress, applying, if we get a better name, we can change this later.

- Arnaldo

I agree that "tracing_path" seems a bit heavy. Why not using tracefs here like for the previous changes?

#17 lore raw

Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object

Quoted 10 lines · Raphaël Beamonte

2015-09-02 9:12 GMT-04:00 Arnaldo Carvalho de Melo <[email protected]>:

Quoted 6 lines

Em Wed, Sep 02, 2015 at 09:56:35AM +0200, Jiri Olsa escreveu:
Humm, here I think that "_path" may look excessive... But tracing_path__ better than debugfs__, so its progress, applying, if we get a better name, we can change this later.

- Arnaldo

I agree that "tracing_path" seems a bit heavy. Why not using tracefs here like for the previous changes?

it's not fs per say, it's 'combination,choice' of debugfs and tracefs that provides 'path' for tracing ;-)

jirka

Reviewed-by
#18 lore raw

Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object

2015-09-04 9:48 GMT-04:00 Jiri Olsa <[email protected]>:

Quoted 2 lines

it's not fs per say, it's 'combination,choice' of debugfs and tracefs that provides 'path' for tracing ;-)

Ok then! Makes sense :) Thanks

2015-09-02 3:56 GMT-04:00 Jiri Olsa <[email protected]>:

Quoted 7 lines

Moving debugfs__strerror_open out of api/fs/debugfs.c, because it's not debugfs specific. It'll be changed to consider tracefs mount as well in following patches.

Renaming it into tracing_path__strerror_open_tp to fit into the namespace. No functional change is intended.

Quoted 8 lines
---
 tools/lib/api/fs/debugfs.c      | 52 ---------------------------------------
 tools/lib/api/fs/tracing_path.c | 54 +++++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h |  3 +++
 tools/perf/builtin-trace.c      |  5 ++--
 4 files changed, 60 insertions(+), 54 deletions(-)
#19 lore raw

[tip:perf/core] tools lib api fs: Move debugfs__strerror_open into tracing_path.c object

In reply to Jiri Olsa
tools lib api fs: Move debugfs__strerror_open into tracing_path.c object
Commit-ID:  988bdb319246dea977a375beee39a5452e99b3ef
Gitweb:     http://git.kernel.org/tip/988bdb319246dea977a375beee39a5452e99b3ef
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:35 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Sep 2015 12:00:58 -0300

tools lib api fs: Move debugfs__strerror_open into tracing_path.c object

Moving debugfs__strerror_open out of api/fs/debugfs.c, because it's not debugfs specific. It'll be changed to consider tracefs mount as well in following patches.

Renaming it into tracing_path__strerror_open_tp to fit into the namespace. No functional change is intended.

---
 tools/lib/api/fs/debugfs.c      | 52 ---------------------------------------
 tools/lib/api/fs/tracing_path.c | 54 +++++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracing_path.h |  3 +++
 tools/perf/builtin-trace.c      |  5 ++--
 4 files changed, 60 insertions(+), 54 deletions(-)
tools/lib/api/fs/debugfs.c +0 -52
index eb7cf4d..c707cfb 100644
@@ -75,55 +75,3 @@ char *debugfs_mount(const char *mountpoint)
 out:
 	return debugfs_mountpoint;
 }
-
-int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename)
-{
-	char sbuf[128];
-
-	switch (err) {
-	case ENOENT:
-		if (debugfs_found) {
-			snprintf(buf, size,
-				 "Error:\tFile %s/%s not found.\n"
-				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 debugfs_mountpoint, filename);
-			break;
-		}
-		snprintf(buf, size, "%s",
-			 "Error:\tUnable to find debugfs\n"
-			 "Hint:\tWas your kernel compiled with debugfs support?\n"
-			 "Hint:\tIs the debugfs filesystem mounted?\n"
-			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
-		break;
-	case EACCES: {
-		const char *mountpoint = debugfs_mountpoint;
-
-		if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
-			const char *tracefs_mntpoint = tracefs_find_mountpoint();
-
-			if (tracefs_mntpoint)
-				mountpoint = tracefs_mntpoint;
-		}
-
-		snprintf(buf, size,
-			 "Error:\tNo permissions to read %s/%s\n"
-			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
-			 debugfs_mountpoint, filename, mountpoint);
-	}
-		break;
-	default:
-		snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
-		break;
-	}
-
-	return 0;
-}
-
-int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
-{
-	char path[PATH_MAX];
-
-	snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*");
-
-	return debugfs__strerror_open(err, buf, size, path);
-}
tools/lib/api/fs/tracing_path.c +54 -0

63 lines not on this page · raw message

tools/lib/api/fs/tracing_path.h +3 -0
index b132dc5..3f233ac 100644
@@ -1,6 +1,8 @@
 #ifndef __API_FS_TRACING_PATH_H
 #define __API_FS_TRACING_PATH_H
 
+#include <linux/types.h>
+
 extern char tracing_path[];
 extern char tracing_events_path[];
 
@@ -10,4 +12,5 @@ const char *tracing_path_mount(void);
 char *get_tracing_file(const char *name);
 void put_tracing_file(char *file);
 
+int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);
 #endif /* __API_FS_TRACING_PATH_H */
tools/perf/builtin-trace.c +3 -2
index 4e3abba..2156532 100644
@@ -17,6 +17,7 @@
  */
 
 #include <traceevent/event-parse.h>
+#include <api/fs/tracing_path.h>
 #include "builtin.h"
 #include "util/color.h"
 #include "util/debug.h"
@@ -2686,11 +2687,11 @@ out_delete_evlist:
 	char errbuf[BUFSIZ];
 
 out_error_sched_stat_runtime:
-	debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
+	tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
 	goto out_error;
 
 out_error_raw_syscalls:
-	debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "raw_syscalls", "sys_(enter|exit)");
+	tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "raw_syscalls", "sys_(enter|exit)");
 	goto out_error;
 
 out_error_mmap:
author reviewer
#20 lore raw

PATCH 6/15 tools lib api: Make tracing_path_strerror_open message generic

In reply to Jiri Olsa

Making tracing_path__strerror_open_tp message generic by mentioning both debugfs/tracefs words in error message plus the tracing_path instead of debugfs_mountpoint.

---
 tools/lib/api/fs/tracing_path.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tools/lib/api/fs/tracing_path.c +10 -10
index 3b3e4f5fc50b..b0ee3b3acef0 100644
@@ -90,33 +90,33 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 
 	switch (err) {
 	case ENOENT:
-		if (debugfs_configured()) {
+		if (debugfs_configured() || tracefs_configured()) {
 			snprintf(buf, size,
 				 "Error:\tFile %s/%s not found.\n"
 				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 debugfs_mountpoint, filename);
+				 tracing_events_path, filename);
 			break;
 		}
 		snprintf(buf, size, "%s",
-			 "Error:\tUnable to find debugfs\n"
-			 "Hint:\tWas your kernel compiled with debugfs support?\n"
-			 "Hint:\tIs the debugfs filesystem mounted?\n"
+			 "Error:\tUnable to find debugfs/tracefs\n"
+			 "Hint:\tWas your kernel compiled with debugfs/tracefs support?\n"
+			 "Hint:\tIs the debugfs/tracefs filesystem mounted?\n"
 			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
 		break;
 	case EACCES: {
-		const char *mountpoint = debugfs_mountpoint;
+		const char *mountpoint = debugfs_find_mountpoint();
 
-		if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
+		if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
 			const char *tracefs_mntpoint = tracefs_find_mountpoint();
 
 			if (tracefs_mntpoint)
-				mountpoint = tracefs_mntpoint;
+				mountpoint = tracefs_find_mountpoint();
 		}
 
 		snprintf(buf, size,
 			 "Error:\tNo permissions to read %s/%s\n"
 			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
-			 debugfs_mountpoint, filename, mountpoint);
+			 tracing_events_path, filename, mountpoint);
 	}
 		break;
 	default:
@@ -131,7 +131,7 @@ int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *
 {
 	char path[PATH_MAX];
 
-	snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*");
+	snprintf(path, PATH_MAX, "%s/%s", sys, name ?: "*");
 
 	return strerror_open(err, buf, size, path);
 }
Signature · 1 line
2.4.3
#21 lore raw

Re: [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic

Em Wed, Sep 02, 2015 at 09:56:36AM +0200, Jiri Olsa escreveu:

Quoted 1 line

Making tracing_path__strerror_open_tp message generic by mentioning

What means "making message generic"? What is the current behaviour you think is problematic. what is the new behaviour ad why do you think it is better?

The test for ENOENT became confusing, i.e. since this was a test for "tracefs", if debugfs_configured() returned true, i.e. debugfs _was_ found in the system, then, the message makes sense, even if probably could be made better, i.e. isn't true that if CONFIG_DEBUGFS is configured and furthermore, debugfs_configure() returns true, then it should be something like CONFIG_TRACEFS that needs enabling?

I applied all patches before this one, BTW.

- Arnaldo

Quoted 14 lines

both debugfs/tracefs words in error message plus the tracing_path instead of debugfs_mountpoint.

---
 tools/lib/api/fs/tracing_path.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tools/lib/api/fs/tracing_path.c +0 -0
index 3b3e4f5fc50b..b0ee3b3acef0 100644

tools/lib/api/fs/tracing_path.c static int strerror_open(int err, char *buf, size_t size, const char *filename) · line 97

Quoted 10 lines
tools/lib/api/fs/tracing_path.c +2 -2
@@ -90,33 +90,33 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 
 	switch (err) {
 	case ENOENT:
-		if (debugfs_configured()) {
+		if (debugfs_configured() || tracefs_configured()) {
 			snprintf(buf, size,
 				 "Error:\tFile %s/%s not found.\n"
 				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 debugfs_mountpoint, filename);
+				 tracing_events_path, filename);

Humm

Quoted 43 lines
tools/lib/api/fs/tracing_path.c +8 -8
 			break;
 		}
 		snprintf(buf, size, "%s",
-			 "Error:\tUnable to find debugfs\n"
-			 "Hint:\tWas your kernel compiled with debugfs support?\n"
-			 "Hint:\tIs the debugfs filesystem mounted?\n"
+			 "Error:\tUnable to find debugfs/tracefs\n"
+			 "Hint:\tWas your kernel compiled with debugfs/tracefs support?\n"
+			 "Hint:\tIs the debugfs/tracefs filesystem mounted?\n"
 			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
 		break;
 	case EACCES: {
-		const char *mountpoint = debugfs_mountpoint;
+		const char *mountpoint = debugfs_find_mountpoint();
 
-		if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
+		if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
 			const char *tracefs_mntpoint = tracefs_find_mountpoint();
 
 			if (tracefs_mntpoint)
-				mountpoint = tracefs_mntpoint;
+				mountpoint = tracefs_find_mountpoint();
 		}
 
 		snprintf(buf, size,
 			 "Error:\tNo permissions to read %s/%s\n"
 			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
-			 debugfs_mountpoint, filename, mountpoint);
+			 tracing_events_path, filename, mountpoint);
 	}
 		break;
 	default:
@@ -131,7 +131,7 @@ int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *
 {
 	char path[PATH_MAX];
 
-	snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*");
+	snprintf(path, PATH_MAX, "%s/%s", sys, name ?: "*");
 
 	return strerror_open(err, buf, size, path);
 }
Signature · 1 line
2.4.3
#22 lore raw

Re: [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic

Quoted 33 lines · Arnaldo Carvalho de Melo

Em Wed, Sep 02, 2015 at 09:56:36AM +0200, Jiri Olsa escreveu:

Quoted 1 line

Making tracing_path__strerror_open_tp message generic by mentioning

What means "making message generic"? What is the current behaviour you think is problematic. what is the new behaviour ad why do you think it is better?

The test for ENOENT became confusing, i.e. since this was a test for "tracefs", if debugfs_configured() returned true, i.e. debugfs _was_ found in the system, then, the message makes sense, even if probably could be made better, i.e. isn't true that if CONFIG_DEBUGFS is configured and furthermore, debugfs_configure() returns true, then it should be something like CONFIG_TRACEFS that needs enabling?

I applied all patches before this one, BTW.

- Arnaldo

Quoted 15 lines

both debugfs/tracefs words in error message plus the tracing_path instead of debugfs_mountpoint.

---
 tools/lib/api/fs/tracing_path.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tools/lib/api/fs/tracing_path.c +0 -0
index 3b3e4f5fc50b..b0ee3b3acef0 100644
@@ -90,33 +90,33 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 
Quoted 11 lines

tools/lib/api/fs/tracing_path.c static int strerror_open(int err, char *buf, size_t size, const char *filename) · line 97

Quoted 9 lines
tools/lib/api/fs/tracing_path.c +2 -2
 	switch (err) {
 	case ENOENT:
-		if (debugfs_configured()) {
+		if (debugfs_configured() || tracefs_configured()) {
 			snprintf(buf, size,
 				 "Error:\tFile %s/%s not found.\n"
 				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 debugfs_mountpoint, filename);
+				 tracing_events_path, filename);

Humm

we will get here if we can't find the tracepoint, but one of debugfs or tracefs is configured, which means you probably want some tracepoint which wasn't compiled in your kernel

before it did not take into account we could have tracefs configured thats what other changes in here are about, to consider tracefs mount

jirka

#23 lore raw

Re: [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic

Em Wed, Sep 02, 2015 at 03:44:50PM +0200, Jiri Olsa escreveu:

Quoted 46 lines · Arnaldo Carvalho de Melo
Quoted 33 lines

Em Wed, Sep 02, 2015 at 09:56:36AM +0200, Jiri Olsa escreveu:

Quoted 1 line

Making tracing_path__strerror_open_tp message generic by mentioning

What means "making message generic"? What is the current behaviour you think is problematic. what is the new behaviour ad why do you think it is better?

The test for ENOENT became confusing, i.e. since this was a test for "tracefs", if debugfs_configured() returned true, i.e. debugfs _was_ found in the system, then, the message makes sense, even if probably could be made better, i.e. isn't true that if CONFIG_DEBUGFS is configured and furthermore, debugfs_configure() returns true, then it should be something like CONFIG_TRACEFS that needs enabling?

I applied all patches before this one, BTW.

- Arnaldo

Quoted 15 lines

both debugfs/tracefs words in error message plus the tracing_path instead of debugfs_mountpoint.

---
 tools/lib/api/fs/tracing_path.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tools/lib/api/fs/tracing_path.c +0 -0
index 3b3e4f5fc50b..b0ee3b3acef0 100644
@@ -90,33 +90,33 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 
Quoted 11 lines

tools/lib/api/fs/tracing_path.c static int strerror_open(int err, char *buf, size_t size, const char *filename) · line 97

Quoted 9 lines
tools/lib/api/fs/tracing_path.c +2 -2
 	switch (err) {
 	case ENOENT:
-		if (debugfs_configured()) {
+		if (debugfs_configured() || tracefs_configured()) {
 			snprintf(buf, size,
 				 "Error:\tFile %s/%s not found.\n"
 				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 debugfs_mountpoint, filename);
+				 tracing_events_path, filename);

Humm

Quoted 6 lines

we will get here if we can't find the tracepoint, but one of debugfs or tracefs is configured, which means you probably want some tracepoint which wasn't compiled in your kernel

before it did not take into account we could have tracefs configured thats what other changes in here are about, to consider tracefs mount

Ok, that helps, will add the above as an comment.

Somehow I was seeing this as not finding the mountpoints :-\

- Arnaldo

#24 lore raw

[tip:perf/core] tools lib api fs: Make tracing_path_strerror_open message generic

In reply to Jiri Olsa
tools lib api fs: Make tracing_path_strerror_open message generic
Commit-ID:  4f234f06d608635a1cff936131285a91af213b37
Gitweb:     http://git.kernel.org/tip/4f234f06d608635a1cff936131285a91af213b37
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:36 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:14 -0300

tools lib api fs: Make tracing_path_strerror_open message generic

Making tracing_path__strerror_open_tp message generic by mentioning both debugfs/tracefs words in error message plus the tracing_path instead of debugfs_mountpoint.

Cc David Ahern <[email protected]>
Cc Matt Fleming <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Raphael Beamonte <[email protected]>
Cc Steven Rostedt <[email protected]>
[ Add comment for the ENOENT case out of this patch discussion thread ]
---
 tools/lib/api/fs/tracing_path.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
tools/lib/api/fs/tracing_path.c +16 -10
index 3b3e4f5..1e0bb0d 100644
@@ -90,33 +90,39 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 
 	switch (err) {
 	case ENOENT:
-		if (debugfs_configured()) {
+		/*
+		 * We will get here if we can't find the tracepoint, but one of
+		 * debugfs or tracefs is configured, which means you probably
+		 * want some tracepoint which wasn't compiled in your kernel.
+		 * - jirka
+		 */
+		if (debugfs_configured() || tracefs_configured()) {
 			snprintf(buf, size,
 				 "Error:\tFile %s/%s not found.\n"
 				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
-				 debugfs_mountpoint, filename);
+				 tracing_events_path, filename);
 			break;
 		}
 		snprintf(buf, size, "%s",
-			 "Error:\tUnable to find debugfs\n"
-			 "Hint:\tWas your kernel compiled with debugfs support?\n"
-			 "Hint:\tIs the debugfs filesystem mounted?\n"
+			 "Error:\tUnable to find debugfs/tracefs\n"
+			 "Hint:\tWas your kernel compiled with debugfs/tracefs support?\n"
+			 "Hint:\tIs the debugfs/tracefs filesystem mounted?\n"
 			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
 		break;
 	case EACCES: {
-		const char *mountpoint = debugfs_mountpoint;
+		const char *mountpoint = debugfs_find_mountpoint();
 
-		if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
+		if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
 			const char *tracefs_mntpoint = tracefs_find_mountpoint();
 
 			if (tracefs_mntpoint)
-				mountpoint = tracefs_mntpoint;
+				mountpoint = tracefs_find_mountpoint();
 		}
 
 		snprintf(buf, size,
 			 "Error:\tNo permissions to read %s/%s\n"
 			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
-			 debugfs_mountpoint, filename, mountpoint);
+			 tracing_events_path, filename, mountpoint);
 	}
 		break;
 	default:
@@ -131,7 +137,7 @@ int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *
 {
 	char path[PATH_MAX];
 
-	snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*");
+	snprintf(path, PATH_MAX, "%s/%s", sys, name ?: "*");
 
 	return strerror_open(err, buf, size, path);
 }
author reviewer
#25 lore raw

PATCH 7/15 tools lib api: Add STR and PATH_MAX macros to fs object

In reply to Jiri Olsa

We're going to get rid of findfs.h in following patches, but we'll still need these macros.

---
 tools/lib/api/fs/fs.c | 3 +++
 tools/lib/api/fs/fs.h | 8 ++++++++
 2 files changed, 11 insertions(+)
tools/lib/api/fs/fs.c +3 -0
index 128ef6332a6b..5e838d3c419d 100644
@@ -15,6 +15,9 @@
 #include "debugfs.h"
 #include "fs.h"
 
+#define _STR(x) #x
+#define STR(x) _STR(x)
+
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
 	0,
tools/lib/api/fs/fs.h +8 -0
index 6caa2bbc6cec..fd6288d73383 100644
@@ -1,6 +1,14 @@
 #ifndef __API_FS__
 #define __API_FS__
 
+/*
+ * On most systems <limits.h> would have given us this, but  not on some systems
+ * (e.g. GNU/Hurd).
+ */
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
 #ifndef SYSFS_MAGIC
 #define SYSFS_MAGIC            0x62656572
 #endif
Signature · 1 line
2.4.3
#26 lore raw

[tip:perf/core] tools lib api fs: Add STR and PATH_MAX macros to fs object

tools lib api fs: Add STR and PATH_MAX macros to fs object
Commit-ID:  b86b0d3570273c6ddc16b1972e82bf7778346286
Gitweb:     http://git.kernel.org/tip/b86b0d3570273c6ddc16b1972e82bf7778346286
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:37 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Sep 2015 12:00:58 -0300

tools lib api fs: Add STR and PATH_MAX macros to fs object

We're going to get rid of findfs.h in following patches, but we'll still need these macros.

---
 tools/lib/api/fs/fs.c | 3 +++
 tools/lib/api/fs/fs.h | 8 ++++++++
 2 files changed, 11 insertions(+)
tools/lib/api/fs/fs.c +3 -0
index 128ef63..5e838d3 100644
@@ -15,6 +15,9 @@
 #include "debugfs.h"
 #include "fs.h"
 
+#define _STR(x) #x
+#define STR(x) _STR(x)
+
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
 	0,
tools/lib/api/fs/fs.h +8 -0
index 6caa2bb..fd6288d 100644
@@ -1,6 +1,14 @@
 #ifndef __API_FS__
 #define __API_FS__
 
+/*
+ * On most systems <limits.h> would have given us this, but  not on some systems
+ * (e.g. GNU/Hurd).
+ */
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
 #ifndef SYSFS_MAGIC
 #define SYSFS_MAGIC            0x62656572
 #endif
author reviewer
#27 lore raw

PATCH 8/15 tools lib api: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c

In reply to Jiri Olsa

There's no need to export SYSFS_MAGIC PROC_SUPER_MAGIC in fs.h. Leave them in the fs.c.

---
 tools/lib/api/fs/fs.c | 8 ++++++++
 tools/lib/api/fs/fs.h | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)
tools/lib/api/fs/fs.c +8 -0
index 5e838d3c419d..0700eb953495 100644
@@ -18,6 +18,14 @@
 #define _STR(x) #x
 #define STR(x) _STR(x)
 
+#ifndef SYSFS_MAGIC
+#define SYSFS_MAGIC            0x62656572
+#endif
+
+#ifndef PROC_SUPER_MAGIC
+#define PROC_SUPER_MAGIC       0x9fa0
+#endif
+
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
 	0,
tools/lib/api/fs/fs.h +0 -8
index fd6288d73383..674efc8dfd9b 100644
@@ -9,14 +9,6 @@
 #define PATH_MAX 4096
 #endif
 
-#ifndef SYSFS_MAGIC
-#define SYSFS_MAGIC            0x62656572
-#endif
-
-#ifndef PROC_SUPER_MAGIC
-#define PROC_SUPER_MAGIC       0x9fa0
-#endif
-
 const char *sysfs__mountpoint(void);
 const char *procfs__mountpoint(void);
 
Signature · 1 line
2.4.3
#28 lore raw

[tip:perf/core] tools lib api fs: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c

tools lib api fs: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c
Commit-ID:  41e3a1fece31d0b2383281e4a917ff4b16fa9223
Gitweb:     http://git.kernel.org/tip/41e3a1fece31d0b2383281e4a917ff4b16fa9223
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:38 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Sep 2015 12:00:59 -0300

tools lib api fs: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c

There's no need to export SYSFS_MAGIC PROC_SUPER_MAGIC in fs.h. Leave them in the fs.c.

---
 tools/lib/api/fs/fs.c | 8 ++++++++
 tools/lib/api/fs/fs.h | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)
tools/lib/api/fs/fs.c +8 -0
index 5e838d3..0700eb9 100644
@@ -18,6 +18,14 @@
 #define _STR(x) #x
 #define STR(x) _STR(x)
 
+#ifndef SYSFS_MAGIC
+#define SYSFS_MAGIC            0x62656572
+#endif
+
+#ifndef PROC_SUPER_MAGIC
+#define PROC_SUPER_MAGIC       0x9fa0
+#endif
+
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
 	0,
tools/lib/api/fs/fs.h +0 -8
index fd6288d..674efc8 100644
@@ -9,14 +9,6 @@
 #define PATH_MAX 4096
 #endif
 
-#ifndef SYSFS_MAGIC
-#define SYSFS_MAGIC            0x62656572
-#endif
-
-#ifndef PROC_SUPER_MAGIC
-#define PROC_SUPER_MAGIC       0x9fa0
-#endif
-
 const char *sysfs__mountpoint(void);
 const char *procfs__mountpoint(void);
 
author reviewer
#29 lore raw

PATCH 9/15 tools lib api: Add debugfs into fs.c object

In reply to Jiri Olsa

Adding debugfs support into fs.c framework. It'll replace the debugfs object functionality in following patches.

---
 tools/lib/api/fs/fs.c | 31 +++++++++++++++++++++++++------
 tools/lib/api/fs/fs.h |  1 +
 2 files changed, 26 insertions(+), 6 deletions(-)
tools/lib/api/fs/fs.c +25 -6
index 0700eb953495..798052cbc7c0 100644
@@ -1,5 +1,3 @@
-/* TODO merge/factor in debugfs.c here */
-
 #include <ctype.h>
 #include <errno.h>
 #include <stdbool.h>
@@ -26,6 +24,10 @@
 #define PROC_SUPER_MAGIC       0x9fa0
 #endif
 
+#ifndef DEBUGFS_MAGIC
+#define DEBUGFS_MAGIC          0x64626720
+#endif
+
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
 	0,
@@ -36,6 +38,16 @@ static const char * const procfs__known_mountpoints[] = {
 	0,
 };
 
+#ifndef DEBUGFS_DEFAULT_PATH
+#define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug"
+#endif
+
+static const char * const debugfs__known_mountpoints[] = {
+	DEBUGFS_DEFAULT_PATH,
+	"/debug",
+	0,
+};
+
 struct fs {
 	const char		*name;
 	const char * const	*mounts;
@@ -45,8 +57,9 @@ struct fs {
 };
 
 enum {
-	FS__SYSFS  = 0,
-	FS__PROCFS = 1,
+	FS__SYSFS   = 0,
+	FS__PROCFS  = 1,
+	FS__DEBUGFS = 2,
 };
 
 static struct fs fs__entries[] = {
@@ -60,6 +73,11 @@ static struct fs fs__entries[] = {
 		.mounts	= procfs__known_mountpoints,
 		.magic	= PROC_SUPER_MAGIC,
 	},
+	[FS__DEBUGFS] = {
+		.name	= "debugfs",
+		.mounts	= debugfs__known_mountpoints,
+		.magic	= DEBUGFS_MAGIC,
+	},
 };
 
 static bool fs__read_mounts(struct fs *fs)
@@ -176,8 +194,9 @@ const char *name##__mountpoint(void)	\
 	return fs__mountpoint(idx);	\
 }
 
-FS__MOUNTPOINT(sysfs,  FS__SYSFS);
-FS__MOUNTPOINT(procfs, FS__PROCFS);
+FS__MOUNTPOINT(sysfs,   FS__SYSFS);
+FS__MOUNTPOINT(procfs,  FS__PROCFS);
+FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
 
 int filename__read_int(const char *filename, int *value)
 {
tools/lib/api/fs/fs.h +1 -0
index 674efc8dfd9b..a4e6b1d93d2f 100644
@@ -11,6 +11,7 @@
 
 const char *sysfs__mountpoint(void);
 const char *procfs__mountpoint(void);
+const char *debugfs__mountpoint(void);
 
 int filename__read_int(const char *filename, int *value);
 int sysctl__read_int(const char *sysctl, int *value);
Signature · 1 line
2.4.3
#30 lore raw

[tip:perf/core] tools lib api fs: Add debugfs into fs.c object

tools lib api fs: Add debugfs into fs.c object
Commit-ID:  8ccfabdb873df2e18b235bfaf2722f7528d220f1
Gitweb:     http://git.kernel.org/tip/8ccfabdb873df2e18b235bfaf2722f7528d220f1
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:39 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Sep 2015 12:00:59 -0300

tools lib api fs: Add debugfs into fs.c object

Adding debugfs support into fs.c framework. It'll replace the debugfs object functionality in following patches.

---
 tools/lib/api/fs/fs.c | 31 +++++++++++++++++++++++++------
 tools/lib/api/fs/fs.h |  1 +
 2 files changed, 26 insertions(+), 6 deletions(-)
tools/lib/api/fs/fs.c +25 -6
index 0700eb9..798052c 100644
@@ -1,5 +1,3 @@
-/* TODO merge/factor in debugfs.c here */
-
 #include <ctype.h>
 #include <errno.h>
 #include <stdbool.h>
@@ -26,6 +24,10 @@
 #define PROC_SUPER_MAGIC       0x9fa0
 #endif
 
+#ifndef DEBUGFS_MAGIC
+#define DEBUGFS_MAGIC          0x64626720
+#endif
+
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
 	0,
@@ -36,6 +38,16 @@ static const char * const procfs__known_mountpoints[] = {
 	0,
 };
 
+#ifndef DEBUGFS_DEFAULT_PATH
+#define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug"
+#endif
+
+static const char * const debugfs__known_mountpoints[] = {
+	DEBUGFS_DEFAULT_PATH,
+	"/debug",
+	0,
+};
+
 struct fs {
 	const char		*name;
 	const char * const	*mounts;
@@ -45,8 +57,9 @@ struct fs {
 };
 
 enum {
-	FS__SYSFS  = 0,
-	FS__PROCFS = 1,
+	FS__SYSFS   = 0,
+	FS__PROCFS  = 1,
+	FS__DEBUGFS = 2,
 };
 
 static struct fs fs__entries[] = {
@@ -60,6 +73,11 @@ static struct fs fs__entries[] = {
 		.mounts	= procfs__known_mountpoints,
 		.magic	= PROC_SUPER_MAGIC,
 	},
+	[FS__DEBUGFS] = {
+		.name	= "debugfs",
+		.mounts	= debugfs__known_mountpoints,
+		.magic	= DEBUGFS_MAGIC,
+	},
 };
 
 static bool fs__read_mounts(struct fs *fs)
@@ -176,8 +194,9 @@ const char *name##__mountpoint(void)	\
 	return fs__mountpoint(idx);	\
 }
 
-FS__MOUNTPOINT(sysfs,  FS__SYSFS);
-FS__MOUNTPOINT(procfs, FS__PROCFS);
+FS__MOUNTPOINT(sysfs,   FS__SYSFS);
+FS__MOUNTPOINT(procfs,  FS__PROCFS);
+FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
 
 int filename__read_int(const char *filename, int *value)
 {
tools/lib/api/fs/fs.h +1 -0
index 674efc8..a4e6b1d 100644
@@ -11,6 +11,7 @@
 
 const char *sysfs__mountpoint(void);
 const char *procfs__mountpoint(void);
+const char *debugfs__mountpoint(void);
 
 int filename__read_int(const char *filename, int *value);
 int sysctl__read_int(const char *sysctl, int *value);
author reviewer
#31 lore raw

PATCH 10/15 tools lib api: Add tracefs into fs.c object

In reply to Jiri Olsa

Adding tracefs support into fs.c framework. It'll replace the tracefs object functionality in following patches.

---
 tools/lib/api/fs/fs.c | 28 ++++++++++++++++++++++++++++
 tools/lib/api/fs/fs.h |  1 +
 2 files changed, 29 insertions(+)
tools/lib/api/fs/fs.c +28 -0
index 798052cbc7c0..ef16d2a83a27 100644
@@ -28,6 +28,10 @@
 #define DEBUGFS_MAGIC          0x64626720
 #endif
 
+#ifndef TRACEFS_MAGIC
+#define TRACEFS_MAGIC          0x74726163
+#endif
+
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
 	0,
@@ -48,6 +52,19 @@ static const char * const debugfs__known_mountpoints[] = {
 	0,
 };
 
+
+#ifndef TRACEFS_DEFAULT_PATH
+#define TRACEFS_DEFAULT_PATH "/sys/kernel/tracing"
+#endif
+
+static const char * const tracefs__known_mountpoints[] = {
+	TRACEFS_DEFAULT_PATH,
+	"/sys/kernel/debug/tracing",
+	"/tracing",
+	"/trace",
+	0,
+};
+
 struct fs {
 	const char		*name;
 	const char * const	*mounts;
@@ -60,8 +77,13 @@ enum {
 	FS__SYSFS   = 0,
 	FS__PROCFS  = 1,
 	FS__DEBUGFS = 2,
+	FS__TRACEFS = 3,
 };
 
+#ifndef TRACEFS_MAGIC
+#define TRACEFS_MAGIC 0x74726163
+#endif
+
 static struct fs fs__entries[] = {
 	[FS__SYSFS] = {
 		.name	= "sysfs",
@@ -78,6 +100,11 @@ static struct fs fs__entries[] = {
 		.mounts	= debugfs__known_mountpoints,
 		.magic	= DEBUGFS_MAGIC,
 	},
+	[FS__TRACEFS] = {
+		.name	= "tracefs",
+		.mounts	= tracefs__known_mountpoints,
+		.magic	= TRACEFS_MAGIC,
+	},
 };
 
 static bool fs__read_mounts(struct fs *fs)
@@ -197,6 +224,7 @@ const char *name##__mountpoint(void)	\
 FS__MOUNTPOINT(sysfs,   FS__SYSFS);
 FS__MOUNTPOINT(procfs,  FS__PROCFS);
 FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
+FS__MOUNTPOINT(tracefs, FS__TRACEFS);
 
 int filename__read_int(const char *filename, int *value)
 {
tools/lib/api/fs/fs.h +1 -0
index a4e6b1d93d2f..9013227ae0d1 100644
@@ -12,6 +12,7 @@
 const char *sysfs__mountpoint(void);
 const char *procfs__mountpoint(void);
 const char *debugfs__mountpoint(void);
+const char *tracefs__mountpoint(void);
 
 int filename__read_int(const char *filename, int *value);
 int sysctl__read_int(const char *sysctl, int *value);
Signature · 1 line
2.4.3
#32 lore raw

[tip:perf/core] tools lib api fs: Add tracefs into fs.c object

tools lib api fs: Add tracefs into fs.c object
Commit-ID:  c495afb4988dcbb8bae11b8f1bbb7e11f172672b
Gitweb:     http://git.kernel.org/tip/c495afb4988dcbb8bae11b8f1bbb7e11f172672b
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:40 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Sep 2015 12:01:00 -0300

tools lib api fs: Add tracefs into fs.c object

Adding tracefs support into fs.c framework. It'll replace the tracefs object functionality in following patches.

---
 tools/lib/api/fs/fs.c | 28 ++++++++++++++++++++++++++++
 tools/lib/api/fs/fs.h |  1 +
 2 files changed, 29 insertions(+)
tools/lib/api/fs/fs.c +28 -0
index 798052c..ef16d2a 100644
@@ -28,6 +28,10 @@
 #define DEBUGFS_MAGIC          0x64626720
 #endif
 
+#ifndef TRACEFS_MAGIC
+#define TRACEFS_MAGIC          0x74726163
+#endif
+
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
 	0,
@@ -48,6 +52,19 @@ static const char * const debugfs__known_mountpoints[] = {
 	0,
 };
 
+
+#ifndef TRACEFS_DEFAULT_PATH
+#define TRACEFS_DEFAULT_PATH "/sys/kernel/tracing"
+#endif
+
+static const char * const tracefs__known_mountpoints[] = {
+	TRACEFS_DEFAULT_PATH,
+	"/sys/kernel/debug/tracing",
+	"/tracing",
+	"/trace",
+	0,
+};
+
 struct fs {
 	const char		*name;
 	const char * const	*mounts;
@@ -60,8 +77,13 @@ enum {
 	FS__SYSFS   = 0,
 	FS__PROCFS  = 1,
 	FS__DEBUGFS = 2,
+	FS__TRACEFS = 3,
 };
 
+#ifndef TRACEFS_MAGIC
+#define TRACEFS_MAGIC 0x74726163
+#endif
+
 static struct fs fs__entries[] = {
 	[FS__SYSFS] = {
 		.name	= "sysfs",
@@ -78,6 +100,11 @@ static struct fs fs__entries[] = {
 		.mounts	= debugfs__known_mountpoints,
 		.magic	= DEBUGFS_MAGIC,
 	},
+	[FS__TRACEFS] = {
+		.name	= "tracefs",
+		.mounts	= tracefs__known_mountpoints,
+		.magic	= TRACEFS_MAGIC,
+	},
 };
 
 static bool fs__read_mounts(struct fs *fs)
@@ -197,6 +224,7 @@ const char *name##__mountpoint(void)	\
 FS__MOUNTPOINT(sysfs,   FS__SYSFS);
 FS__MOUNTPOINT(procfs,  FS__PROCFS);
 FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
+FS__MOUNTPOINT(tracefs, FS__TRACEFS);
 
 int filename__read_int(const char *filename, int *value)
 {
tools/lib/api/fs/fs.h +1 -0
index a4e6b1d..9013227 100644
@@ -12,6 +12,7 @@
 const char *sysfs__mountpoint(void);
 const char *procfs__mountpoint(void);
 const char *debugfs__mountpoint(void);
+const char *tracefs__mountpoint(void);
 
 int filename__read_int(const char *filename, int *value);
 int sysctl__read_int(const char *sysctl, int *value);
author reviewer
#33 lore raw

PATCH 11/15 tools lib api: Add mount support for fs

In reply to Jiri Olsa

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that tries to mount the filesystem in case no mount is found.

---
 tools/lib/api/fs/fs.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 tools/lib/api/fs/fs.h | 15 +++++++++++----
 2 files changed, 50 insertions(+), 9 deletions(-)
tools/lib/api/fs/fs.c +39 -5
index ef16d2a83a27..bc93baf33fff 100644
@@ -9,6 +9,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys/mount.h>
 
 #include "debugfs.h"
 #include "fs.h"
@@ -215,16 +216,49 @@ static const char *fs__mountpoint(int idx)
 	return fs__get_mountpoint(fs);
 }
 
-#define FS__MOUNTPOINT(name, idx)	\
+static const char *mount_overload(struct fs *fs)
+{
+	size_t name_len = strlen(fs->name);
+	/* "PERF_" + name + "_ENVIRONMENT" + '\0' */
+	char upper_name[5 + name_len + 12 + 1];
+
+	snprintf(upper_name, name_len, "PERF_%s_ENVIRONMENT", fs->name);
+	mem_toupper(upper_name, name_len);
+
+	return getenv(upper_name) ?: *fs->mounts;
+}
+
+static const char *fs__mount(int idx)
+{
+	struct fs *fs = &fs__entries[idx];
+	const char *mountpoint;
+
+	if (fs__mountpoint(idx))
+		return (const char *)fs->path;
+
+	mountpoint = mount_overload(fs);
+
+	if (mount(NULL, mountpoint, fs->name, 0, NULL) < 0)
+		return NULL;
+
+	return fs__check_mounts(fs) ? fs->path : NULL;
+}
+
+#define FS(name, idx)			\
 const char *name##__mountpoint(void)	\
 {					\
 	return fs__mountpoint(idx);	\
+}					\
+					\
+const char *name##__mount(void)		\
+{					\
+	return fs__mount(idx);		\
 }
 
-FS__MOUNTPOINT(sysfs,   FS__SYSFS);
-FS__MOUNTPOINT(procfs,  FS__PROCFS);
-FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
-FS__MOUNTPOINT(tracefs, FS__TRACEFS);
+FS(sysfs,   FS__SYSFS);
+FS(procfs,  FS__PROCFS);
+FS(debugfs, FS__DEBUGFS);
+FS(tracefs, FS__TRACEFS);
 
 int filename__read_int(const char *filename, int *value)
 {
tools/lib/api/fs/fs.h +11 -4
index 9013227ae0d1..a9627ea5e6ae 100644
@@ -9,10 +9,17 @@
 #define PATH_MAX 4096
 #endif
 
-const char *sysfs__mountpoint(void);
-const char *procfs__mountpoint(void);
-const char *debugfs__mountpoint(void);
-const char *tracefs__mountpoint(void);
+#define FS(name)				\
+	const char *name##__mountpoint(void);	\
+	const char *name##__mount(void);
+
+FS(sysfs)
+FS(procfs)
+FS(debugfs)
+FS(tracefs)
+
+#undef FS
+
 
 int filename__read_int(const char *filename, int *value);
 int sysctl__read_int(const char *sysctl, int *value);
Signature · 1 line
2.4.3
#34 lore raw

Re: [PATCH 11/15] tools lib api: Add mount support for fs

2015-09-02 3:56 GMT-04:00 Jiri Olsa <[email protected]>:

Quoted 9 lines

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that tries to mount the filesystem in case no mount is found.

---
 tools/lib/api/fs/fs.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 tools/lib/api/fs/fs.h | 15 +++++++++++----
 2 files changed, 50 insertions(+), 9 deletions(-)

Why automatic mounting the **fs filesystems?
Isn't it better to let the user decide when and where to mount it if s/he forgot to do it before? Forcing a mount is also potentially forcing to umount then mount when mounting has been forgotten before.

Quoted 96 lines
tools/lib/api/fs/fs.c +39 -5
index ef16d2a83a27..bc93baf33fff 100644
@@ -9,6 +9,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys/mount.h>
 
 #include "debugfs.h"
 #include "fs.h"
@@ -215,16 +216,49 @@ static const char *fs__mountpoint(int idx)
        return fs__get_mountpoint(fs);
 }
 
-#define FS__MOUNTPOINT(name, idx)      \
+static const char *mount_overload(struct fs *fs)
+{
+       size_t name_len = strlen(fs->name);
+       /* "PERF_" + name + "_ENVIRONMENT" + '\0' */
+       char upper_name[5 + name_len + 12 + 1];
+
+       snprintf(upper_name, name_len, "PERF_%s_ENVIRONMENT", fs->name);
+       mem_toupper(upper_name, name_len);
+
+       return getenv(upper_name) ?: *fs->mounts;
+}
+
+static const char *fs__mount(int idx)
+{
+       struct fs *fs = &fs__entries[idx];
+       const char *mountpoint;
+
+       if (fs__mountpoint(idx))
+               return (const char *)fs->path;
+
+       mountpoint = mount_overload(fs);
+
+       if (mount(NULL, mountpoint, fs->name, 0, NULL) < 0)
+               return NULL;
+
+       return fs__check_mounts(fs) ? fs->path : NULL;
+}
+
+#define FS(name, idx)                  \
 const char *name##__mountpoint(void)   \
 {                                      \
        return fs__mountpoint(idx);     \
+}                                      \
+                                       \
+const char *name##__mount(void)                \
+{                                      \
+       return fs__mount(idx);          \
 }
 
-FS__MOUNTPOINT(sysfs,   FS__SYSFS);
-FS__MOUNTPOINT(procfs,  FS__PROCFS);
-FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
-FS__MOUNTPOINT(tracefs, FS__TRACEFS);
+FS(sysfs,   FS__SYSFS);
+FS(procfs,  FS__PROCFS);
+FS(debugfs, FS__DEBUGFS);
+FS(tracefs, FS__TRACEFS);
 
 int filename__read_int(const char *filename, int *value)
 {
tools/lib/api/fs/fs.h +11 -5
index 9013227ae0d1..a9627ea5e6ae 100644
@@ -9,10 +9,17 @@
 #define PATH_MAX 4096
 #endif
 
-const char *sysfs__mountpoint(void);
-const char *procfs__mountpoint(void);
-const char *debugfs__mountpoint(void);
-const char *tracefs__mountpoint(void);
+#define FS(name)                               \
+       const char *name##__mountpoint(void);   \
+       const char *name##__mount(void);
+
+FS(sysfs)
+FS(procfs)
+FS(debugfs)
+FS(tracefs)
+
+#undef FS
+
 
 int filename__read_int(const char *filename, int *value);
 int sysctl__read_int(const char *sysctl, int *value);
--

2.4.3

#35 lore raw

Re: [PATCH 11/15] tools lib api: Add mount support for fs

Quoted 11 lines · On Fri, 4 Sep 2015 10:14:28 -0400 Raphaël Beamonte…

2015-09-02 3:56 GMT-04:00 Jiri Olsa <[email protected]>:

Quoted 9 lines

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that tries to mount the filesystem in case no mount is found.

---
 tools/lib/api/fs/fs.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 tools/lib/api/fs/fs.h | 15 +++++++++++----
 2 files changed, 50 insertions(+), 9 deletions(-)
Quoted 5 lines

Why automatic mounting the **fs filesystems?
Isn't it better to let the user decide when and where to mount it if s/he forgot to do it before? Forcing a mount is also potentially forcing to umount then mount when mounting has been forgotten before.

tracefs and debugfs have known locations to be mounted at. That's why the kernel supplies it (/sys/kernel/debug and /sys/kernel/trace). Why should we bother the user with this? trace-cmd does the same thing. It automatically mounts the filesystems if they are not mounted.

Would you rather have the tool fail and say "please mount the trace or debugfs file system"? Even if it asked before doing so, that would become rather annoying.

Running perf and trace-cmd should just work, and not expect the user to do more work than can be easily done by the tool.

-- Steve

#36 lore raw

Re: [PATCH 11/15] tools lib api: Add mount support for fs

In reply to Raphaël Beamonte
Quoted 11 lines · Raphaël Beamonte

2015-09-02 3:56 GMT-04:00 Jiri Olsa <[email protected]>:

Quoted 9 lines

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that tries to mount the filesystem in case no mount is found.

---
 tools/lib/api/fs/fs.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 tools/lib/api/fs/fs.h | 15 +++++++++++----
 2 files changed, 50 insertions(+), 9 deletions(-)
Quoted 4 lines

Why automatic mounting the **fs filesystems?
Isn't it better to let the user decide when and where to mount it if s/he forgot to do it before? Forcing a mount is also potentially forcing to umount then mount when mounting has been forgotten before.

well, I guess at some point we decided this was a good idea to make perf more user friendly

AFAICS we do this only for debugfs and tracefs.. procfs and sysfs are mounted most of the time anyway

we could track and unmount on exit, but I'd say let's have someone complaining about it first ;-)

jirka

Quoted 98 lines
Quoted 98 lines
tools/lib/api/fs/fs.c +39 -5
index ef16d2a83a27..bc93baf33fff 100644
@@ -9,6 +9,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys/mount.h>
 
 #include "debugfs.h"
 #include "fs.h"
@@ -215,16 +216,49 @@ static const char *fs__mountpoint(int idx)
        return fs__get_mountpoint(fs);
 }
 
-#define FS__MOUNTPOINT(name, idx)      \
+static const char *mount_overload(struct fs *fs)
+{
+       size_t name_len = strlen(fs->name);
+       /* "PERF_" + name + "_ENVIRONMENT" + '\0' */
+       char upper_name[5 + name_len + 12 + 1];
+
+       snprintf(upper_name, name_len, "PERF_%s_ENVIRONMENT", fs->name);
+       mem_toupper(upper_name, name_len);
+
+       return getenv(upper_name) ?: *fs->mounts;
+}
+
+static const char *fs__mount(int idx)
+{
+       struct fs *fs = &fs__entries[idx];
+       const char *mountpoint;
+
+       if (fs__mountpoint(idx))
+               return (const char *)fs->path;
+
+       mountpoint = mount_overload(fs);
+
+       if (mount(NULL, mountpoint, fs->name, 0, NULL) < 0)
+               return NULL;
+
+       return fs__check_mounts(fs) ? fs->path : NULL;
+}
+
+#define FS(name, idx)                  \
 const char *name##__mountpoint(void)   \
 {                                      \
        return fs__mountpoint(idx);     \
+}                                      \
+                                       \
+const char *name##__mount(void)                \
+{                                      \
+       return fs__mount(idx);          \
 }
 
-FS__MOUNTPOINT(sysfs,   FS__SYSFS);
-FS__MOUNTPOINT(procfs,  FS__PROCFS);
-FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
-FS__MOUNTPOINT(tracefs, FS__TRACEFS);
+FS(sysfs,   FS__SYSFS);
+FS(procfs,  FS__PROCFS);
+FS(debugfs, FS__DEBUGFS);
+FS(tracefs, FS__TRACEFS);
 
 int filename__read_int(const char *filename, int *value)
 {
tools/lib/api/fs/fs.h +11 -5
index 9013227ae0d1..a9627ea5e6ae 100644
@@ -9,10 +9,17 @@
 #define PATH_MAX 4096
 #endif
 
-const char *sysfs__mountpoint(void);
-const char *procfs__mountpoint(void);
-const char *debugfs__mountpoint(void);
-const char *tracefs__mountpoint(void);
+#define FS(name)                               \
+       const char *name##__mountpoint(void);   \
+       const char *name##__mount(void);
+
+FS(sysfs)
+FS(procfs)
+FS(debugfs)
+FS(tracefs)
+
+#undef FS
+
 
 int filename__read_int(const char *filename, int *value);
 int sysctl__read_int(const char *sysctl, int *value);
--

2.4.3

#37 lore raw

Re: [PATCH 11/15] tools lib api: Add mount support for fs

Quoted 17 lines · On Fri, 4 Sep 2015 16:26:31 +0200 Jiri Olsa <[email protected]> wrote:
Quoted 11 lines · Raphaël Beamonte

2015-09-02 3:56 GMT-04:00 Jiri Olsa <[email protected]>:

Quoted 9 lines

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that tries to mount the filesystem in case no mount is found.

---
 tools/lib/api/fs/fs.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 tools/lib/api/fs/fs.h | 15 +++++++++++----
 2 files changed, 50 insertions(+), 9 deletions(-)
Quoted 4 lines

Why automatic mounting the **fs filesystems?
Isn't it better to let the user decide when and where to mount it if s/he forgot to do it before? Forcing a mount is also potentially forcing to umount then mount when mounting has been forgotten before.

Quoted 5 lines

well, I guess at some point we decided this was a good idea to make perf more user friendly

AFAICS we do this only for debugfs and tracefs.. procfs and sysfs are mounted most of the time anyway

Note, if sysfs isn't already mounted, than nothing will get mounted by perf. As sysfs is a requirement to get to /sys/kernel/trace and debug.

Quoted 4 lines

we could track and unmount on exit, but I'd say let's have someone complaining about it first ;-)

Agreed. Although, I use perf/trace-cmd to mount that directory for me :-)

-- Steve

#38 lore raw

Re: [PATCH 11/15] tools lib api: Add mount support for fs

Quoted 5 lines · On Fri, 4 Sep 2015 10:57:00 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 2 lines

AFAICS we do this only for debugfs and tracefs.. procfs and sysfs are mounted most of the time anyway

Note, if sysfs isn't already mounted, than nothing will get mounted by perf. As sysfs is a requirement to get to /sys/kernel/trace and debug.

I will also add that the reason the /sys/kernel/debug directory is created when DEBUGFS is enabled, was specifically so that tools had a place to automatically mount it when needed. That was the entire purpose of that directory.

-- Steve

Reviewed-by
#39 lore raw

Re: [PATCH 11/15] tools lib api: Add mount support for fs

2015-09-04 11:00 GMT-04:00 Steven Rostedt <[email protected]>:

Quoted 4 lines

I will also add that the reason the /sys/kernel/debug directory is created when DEBUGFS is enabled, was specifically so that tools had a place to automatically mount it when needed. That was the entire purpose of that directory.

Makes sense!
It's also true that, as you both mentioned, it makes perf more user friendly. I wasn't sure to what extent that was the purpose though! Thanks for the clarifications!

2015-09-02 3:56 GMT-04:00 Jiri Olsa <[email protected]>:

Quoted 9 lines

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that tries to mount the filesystem in case no mount is found.

---
 tools/lib/api/fs/fs.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 tools/lib/api/fs/fs.h | 15 +++++++++++----
 2 files changed, 50 insertions(+), 9 deletions(-)

The patch is fine by me! My Reviewed-by can be added if wanted :o)

#40 lore raw

[tip:perf/core] tools lib api fs: Add FSTYPE__mount() method

In reply to Jiri Olsa
tools lib api fs: Add FSTYPE__mount() method
Commit-ID:  73ca85ad364769ffa312b1d892816d8fa23a02bf
Gitweb:     http://git.kernel.org/tip/73ca85ad364769ffa312b1d892816d8fa23a02bf
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:41 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Sep 2015 12:01:00 -0300

tools lib api fs: Add FSTYPE__mount() method

Adding FSTYPE__mount (where FSTYPE is, as of now, one of sysfs, procfs, debugfs, tracefs) method that tries to mount the filesystem in case no mount of FSTYPE is found.

---
 tools/lib/api/fs/fs.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 tools/lib/api/fs/fs.h | 15 +++++++++++----
 2 files changed, 50 insertions(+), 9 deletions(-)
tools/lib/api/fs/fs.c +39 -5
index ef16d2a..bc93baf 100644
@@ -9,6 +9,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys/mount.h>
 
 #include "debugfs.h"
 #include "fs.h"
@@ -215,16 +216,49 @@ static const char *fs__mountpoint(int idx)
 	return fs__get_mountpoint(fs);
 }
 
-#define FS__MOUNTPOINT(name, idx)	\
+static const char *mount_overload(struct fs *fs)
+{
+	size_t name_len = strlen(fs->name);
+	/* "PERF_" + name + "_ENVIRONMENT" + '\0' */
+	char upper_name[5 + name_len + 12 + 1];
+
+	snprintf(upper_name, name_len, "PERF_%s_ENVIRONMENT", fs->name);
+	mem_toupper(upper_name, name_len);
+
+	return getenv(upper_name) ?: *fs->mounts;
+}
+
+static const char *fs__mount(int idx)
+{
+	struct fs *fs = &fs__entries[idx];
+	const char *mountpoint;
+
+	if (fs__mountpoint(idx))
+		return (const char *)fs->path;
+
+	mountpoint = mount_overload(fs);
+
+	if (mount(NULL, mountpoint, fs->name, 0, NULL) < 0)
+		return NULL;
+
+	return fs__check_mounts(fs) ? fs->path : NULL;
+}
+
+#define FS(name, idx)			\
 const char *name##__mountpoint(void)	\
 {					\
 	return fs__mountpoint(idx);	\
+}					\
+					\
+const char *name##__mount(void)		\
+{					\
+	return fs__mount(idx);		\
 }
 
-FS__MOUNTPOINT(sysfs,   FS__SYSFS);
-FS__MOUNTPOINT(procfs,  FS__PROCFS);
-FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
-FS__MOUNTPOINT(tracefs, FS__TRACEFS);
+FS(sysfs,   FS__SYSFS);
+FS(procfs,  FS__PROCFS);
+FS(debugfs, FS__DEBUGFS);
+FS(tracefs, FS__TRACEFS);
 
 int filename__read_int(const char *filename, int *value)
 {
tools/lib/api/fs/fs.h +11 -4
index 9013227..a9627ea 100644
@@ -9,10 +9,17 @@
 #define PATH_MAX 4096
 #endif
 
-const char *sysfs__mountpoint(void);
-const char *procfs__mountpoint(void);
-const char *debugfs__mountpoint(void);
-const char *tracefs__mountpoint(void);
+#define FS(name)				\
+	const char *name##__mountpoint(void);	\
+	const char *name##__mount(void);
+
+FS(sysfs)
+FS(procfs)
+FS(debugfs)
+FS(tracefs)
+
+#undef FS
+
 
 int filename__read_int(const char *filename, int *value);
 int sysctl__read_int(const char *sysctl, int *value);
author reviewer
#41 lore raw

PATCH 12/15 tools lib api: Add configured support for fs

In reply to Jiri Olsa

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that returns bool state of the filesystem mount:
true - mounted, false - not mounted

It will not try to mount the filesystem.

---
 tools/lib/api/fs/fs.c | 23 ++++++++++++++---------
 tools/lib/api/fs/fs.h |  5 ++++-
 2 files changed, 18 insertions(+), 10 deletions(-)
tools/lib/api/fs/fs.c +14 -9
index bc93baf33fff..8afe08a99bc6 100644
@@ -244,15 +244,20 @@ static const char *fs__mount(int idx)
 	return fs__check_mounts(fs) ? fs->path : NULL;
 }
 
-#define FS(name, idx)			\
-const char *name##__mountpoint(void)	\
-{					\
-	return fs__mountpoint(idx);	\
-}					\
-					\
-const char *name##__mount(void)		\
-{					\
-	return fs__mount(idx);		\
+#define FS(name, idx)				\
+const char *name##__mountpoint(void)		\
+{						\
+	return fs__mountpoint(idx);		\
+}						\
+						\
+const char *name##__mount(void)			\
+{						\
+	return fs__mount(idx);			\
+}						\
+						\
+bool name##__configured(void)			\
+{						\
+	return name##__mountpoint() != NULL;	\
 }
 
 FS(sysfs,   FS__SYSFS);
tools/lib/api/fs/fs.h +4 -1
index a9627ea5e6ae..f654bcb99d1e 100644
@@ -1,6 +1,8 @@
 #ifndef __API_FS__
 #define __API_FS__
 
+#include <stdbool.h>
+
 /*
  * On most systems <limits.h> would have given us this, but  not on some systems
  * (e.g. GNU/Hurd).
@@ -11,7 +13,8 @@
 
 #define FS(name)				\
 	const char *name##__mountpoint(void);	\
-	const char *name##__mount(void);
+	const char *name##__mount(void);	\
+	bool name##__configured(void);		\
 
 FS(sysfs)
 FS(procfs)
Signature · 1 line
2.4.3
#42 lore raw

Re: [PATCH 12/15] tools lib api: Add configured support for fs

Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:

Quoted 3 lines

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that returns bool state of the filesystem mount:
true - mounted, false - not mounted

Well, why not take the opportunity and call it... name__mounted()? "__configured()" is too vague...

Also there was some cut'n'pasting mistake here... if you agree I can fix it all up and make this change, well, I'm doing it on my local tree, holler if you have any objection :)

- Arnaldo

Quoted 1 line

It will not try to mount the filesystem.

No FSTYPE__configured() (to-be FSTYPE__mounted()) doesn't mount anything, that is what FSTYPE__mount() does :-)

- Arnaldo

Quoted 66 lines
---
 tools/lib/api/fs/fs.c | 23 ++++++++++++++---------
 tools/lib/api/fs/fs.h |  5 ++++-
 2 files changed, 18 insertions(+), 10 deletions(-)
tools/lib/api/fs/fs.c +14 -9
index bc93baf33fff..8afe08a99bc6 100644
@@ -244,15 +244,20 @@ static const char *fs__mount(int idx)
 	return fs__check_mounts(fs) ? fs->path : NULL;
 }
 
-#define FS(name, idx)			\
-const char *name##__mountpoint(void)	\
-{					\
-	return fs__mountpoint(idx);	\
-}					\
-					\
-const char *name##__mount(void)		\
-{					\
-	return fs__mount(idx);		\
+#define FS(name, idx)				\
+const char *name##__mountpoint(void)		\
+{						\
+	return fs__mountpoint(idx);		\
+}						\
+						\
+const char *name##__mount(void)			\
+{						\
+	return fs__mount(idx);			\
+}						\
+						\
+bool name##__configured(void)			\
+{						\
+	return name##__mountpoint() != NULL;	\
 }
 
 FS(sysfs,   FS__SYSFS);
tools/lib/api/fs/fs.h +4 -1
index a9627ea5e6ae..f654bcb99d1e 100644
@@ -1,6 +1,8 @@
 #ifndef __API_FS__
 #define __API_FS__
 
+#include <stdbool.h>
+
 /*
  * On most systems <limits.h> would have given us this, but  not on some systems
  * (e.g. GNU/Hurd).
@@ -11,7 +13,8 @@
 
 #define FS(name)				\
 	const char *name##__mountpoint(void);	\
-	const char *name##__mount(void);
+	const char *name##__mount(void);	\
+	bool name##__configured(void);		\
 
 FS(sysfs)
 FS(procfs)
Signature · 1 line
2.4.3
#43 lore raw

Re: [PATCH 12/15] tools lib api: Add configured support for fs

Em Wed, Sep 02, 2015 at 10:39:31AM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 12 lines

Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:

Quoted 3 lines

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that returns bool state of the filesystem mount:
true - mounted, false - not mounted

Well, why not take the opportunity and call it... name__mounted()? "__configured()" is too vague...

Also there was some cut'n'pasting mistake here... if you agree I can fix it all up and make this change, well, I'm doing it on my local tree, holler if you have any objection :)

Quoted 6 lines

- Arnaldo

Quoted 1 line

It will not try to mount the filesystem.

No FSTYPE__configured() (to-be FSTYPE__mounted()) doesn't mount anything, that is what FSTYPE__mount() does :-)

Argh, now it was me confused, right, __configured() or __mounted() doesn'try to mount anything, as you said, it is just the "Adding name__mount() that in the beginning that needs fixing, the rest of my comment stands.

- Arnaldo

Quoted 69 lines

- Arnaldo

Quoted 66 lines
---
 tools/lib/api/fs/fs.c | 23 ++++++++++++++---------
 tools/lib/api/fs/fs.h |  5 ++++-
 2 files changed, 18 insertions(+), 10 deletions(-)
tools/lib/api/fs/fs.c +14 -9
index bc93baf33fff..8afe08a99bc6 100644
@@ -244,15 +244,20 @@ static const char *fs__mount(int idx)
 	return fs__check_mounts(fs) ? fs->path : NULL;
 }
 
-#define FS(name, idx)			\
-const char *name##__mountpoint(void)	\
-{					\
-	return fs__mountpoint(idx);	\
-}					\
-					\
-const char *name##__mount(void)		\
-{					\
-	return fs__mount(idx);		\
+#define FS(name, idx)				\
+const char *name##__mountpoint(void)		\
+{						\
+	return fs__mountpoint(idx);		\
+}						\
+						\
+const char *name##__mount(void)			\
+{						\
+	return fs__mount(idx);			\
+}						\
+						\
+bool name##__configured(void)			\
+{						\
+	return name##__mountpoint() != NULL;	\
 }
 
 FS(sysfs,   FS__SYSFS);
tools/lib/api/fs/fs.h +4 -1
index a9627ea5e6ae..f654bcb99d1e 100644
@@ -1,6 +1,8 @@
 #ifndef __API_FS__
 #define __API_FS__
 
+#include <stdbool.h>
+
 /*
  * On most systems <limits.h> would have given us this, but  not on some systems
  * (e.g. GNU/Hurd).
@@ -11,7 +13,8 @@
 
 #define FS(name)				\
 	const char *name##__mountpoint(void);	\
-	const char *name##__mount(void);
+	const char *name##__mount(void);	\
+	bool name##__configured(void);		\
 
 FS(sysfs)
 FS(procfs)
Signature · 1 line
2.4.3
#44 lore raw

Re: [PATCH 12/15] tools lib api: Add configured support for fs

In reply to Arnaldo Carvalho de Melo
Quoted 7 lines · Arnaldo Carvalho de Melo

Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:

Quoted 3 lines

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs) interface that returns bool state of the filesystem mount:
true - mounted, false - not mounted

Well, why not take the opportunity and call it... name__mounted()? "__configured()" is too vague...

I mirrored the debugfs/tracefs object interface
we can have another patch changing that

Quoted 11 lines

Also there was some cut'n'pasting mistake here... if you agree I can fix it all up and make this change, well, I'm doing it on my local tree, holler if you have any objection :)

- Arnaldo

Quoted 1 line

It will not try to mount the filesystem.

No FSTYPE__configured() (to-be FSTYPE__mounted()) doesn't mount anything, that is what FSTYPE__mount() does :-)

I stated it just to be clear ;-)

jirka

#45 lore raw

Re: [PATCH 12/15] tools lib api: Add configured support for fs

Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:

Quoted 3 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:

Quoted 1 line

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)

The cut'n'paste error I mentioned was in the above line, BTW.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

interface that returns bool state of the filesystem mount:
true - mounted, false - not mounted

Well, why not take the opportunity and call it... name__mounted()? "__configured()" is too vague...

I mirrored the debugfs/tracefs object interface
we can have another patch changing that

Ok, agreed, will leave it as configured() and then we can change it.

Quoted 11 lines
Quoted 9 lines

Also there was some cut'n'pasting mistake here... if you agree I can fix it all up and make this change, well, I'm doing it on my local tree, holler if you have any objection :)

Quoted 1 line

It will not try to mount the filesystem.

No FSTYPE__configured() (to-be FSTYPE__mounted()) doesn't mount anything, that is what FSTYPE__mount() does :-)

I stated it just to be clear ;-)

Sure, somehow the cut'n'paste error on the first line flipped a bit in my brain, sorry ;-\

- arnaldo

#46 lore raw

Re: [PATCH 12/15] tools lib api: Add configured support for fs

Em Wed, Sep 02, 2015 at 11:17:59AM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 10 lines

Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:

Quoted 3 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:

Quoted 1 line

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)

The cut'n'paste error I mentioned was in the above line, BTW.

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

interface that returns bool state of the filesystem mount:
true - mounted, false - not mounted

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Well, why not take the opportunity and call it... name__mounted()? "__configured()" is too vague...

I mirrored the debugfs/tracefs object interface
we can have another patch changing that

Ok, agreed, will leave it as configured() and then we can change it.

What I have is at my tmp.perf/core branch, out for lunch.

- Arnaldo

Quoted 16 lines
Quoted 11 lines
Quoted 9 lines

Also there was some cut'n'pasting mistake here... if you agree I can fix it all up and make this change, well, I'm doing it on my local tree, holler if you have any objection :)

Quoted 1 line

It will not try to mount the filesystem.

No FSTYPE__configured() (to-be FSTYPE__mounted()) doesn't mount anything, that is what FSTYPE__mount() does :-)

I stated it just to be clear ;-)

Sure, somehow the cut'n'paste error on the first line flipped a bit in my brain, sorry ;-\

- arnaldo

#47 lore raw

Re: [PATCH 12/15] tools lib api: Add configured support for fs

Quoted 14 lines · Arnaldo Carvalho de Melo

Em Wed, Sep 02, 2015 at 11:17:59AM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 13 lines

Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:

Quoted 3 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:

Quoted 1 line

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)

The cut'n'paste error I mentioned was in the above line, BTW.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

interface that returns bool state of the filesystem mount:
true - mounted, false - not mounted

Well, why not take the opportunity and call it... name__mounted()? "__configured()" is too vague...

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I mirrored the debugfs/tracefs object interface
we can have another patch changing that

Ok, agreed, will leave it as configured() and then we can change it.

What I have is at my tmp.perf/core branch, out for lunch.

I can see all of it in your's perf/core apart from:

Applying: tools lib api: Make tracing_path_strerror_open message generic
Applying: tools lib api: Replace debugfs/tracefs objects interface with fs.c
Applying: tools lib api: Remove debugfs, tracefs and findfs objects
Applying: perf tools: Switch to tracing_path interface on appropriate places

should I repost or do you plan to take it? I didn't get any comments on those

thanks,
jirka

#48 lore raw

Re: [PATCH 12/15] tools lib api: Add configured support for fs

Em Fri, Sep 04, 2015 at 09:08:45AM +0200, Jiri Olsa escreveu:

Quoted 22 lines · Arnaldo Carvalho de Melo
Quoted 14 lines

Em Wed, Sep 02, 2015 at 11:17:59AM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 13 lines

Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:

Quoted 3 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:

Quoted 1 line

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)

The cut'n'paste error I mentioned was in the above line, BTW.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

interface that returns bool state of the filesystem mount:
true - mounted, false - not mounted

Well, why not take the opportunity and call it... name__mounted()? "__configured()" is too vague...

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I mirrored the debugfs/tracefs object interface
we can have another patch changing that

Ok, agreed, will leave it as configured() and then we can change it.

What I have is at my tmp.perf/core branch, out for lunch.

Quoted 8 lines

I can see all of it in your's perf/core apart from:

Applying: tools lib api: Make tracing_path_strerror_open message generic
Applying: tools lib api: Replace debugfs/tracefs objects interface with fs.c
Applying: tools lib api: Remove debugfs, tracefs and findfs objects
Applying: perf tools: Switch to tracing_path interface on appropriate places

should I repost or do you plan to take it? I didn't get any comments on those

I'll get back to those, its just that the number of patches in my perf/core branch was getting too high, better flush it a bit, will continue.

If you can just make sure that a rebase on top of my perf/core goes well, that helps.

- Arnaldo

#49 lore raw

Re: [PATCH 12/15] tools lib api: Add configured support for fs

Quoted 30 lines · Arnaldo Carvalho de Melo

Em Fri, Sep 04, 2015 at 09:08:45AM +0200, Jiri Olsa escreveu:

Quoted 29 lines · Arnaldo Carvalho de Melo
Quoted 14 lines

Em Wed, Sep 02, 2015 at 11:17:59AM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 13 lines

Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:

Quoted 3 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:

Quoted 1 line

Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)

The cut'n'paste error I mentioned was in the above line, BTW.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

interface that returns bool state of the filesystem mount:
true - mounted, false - not mounted

Well, why not take the opportunity and call it... name__mounted()? "__configured()" is too vague...

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I mirrored the debugfs/tracefs object interface
we can have another patch changing that

Ok, agreed, will leave it as configured() and then we can change it.

What I have is at my tmp.perf/core branch, out for lunch.

I can see all of it in your's perf/core apart from:

Applying: tools lib api: Make tracing_path_strerror_open message generic
Applying: tools lib api: Replace debugfs/tracefs objects interface with fs.c
Applying: tools lib api: Remove debugfs, tracefs and findfs objects
Applying: perf tools: Switch to tracing_path interface on appropriate places

Quoted 8 lines
Quoted 1 line

should I repost or do you plan to take it? I didn't get any comments on those

I'll get back to those, its just that the number of patches in my perf/core branch was getting too high, better flush it a bit, will continue.

If you can just make sure that a rebase on top of my perf/core goes well, that helps.

I updated my perf/tracing_path branch to your current perf/core no conflicts..

thanks,
jirka

#50 lore raw

[tip:perf/core] tools lib api fs: Add FSTYPE__configured() method

In reply to Jiri Olsa
tools lib api fs: Add FSTYPE__configured() method
Commit-ID:  709adcb33928b5bf965587b23ed6544e964584a3
Gitweb:     http://git.kernel.org/tip/709adcb33928b5bf965587b23ed6544e964584a3
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:42 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Sep 2015 12:01:01 -0300

tools lib api fs: Add FSTYPE__configured() method

Add FSTYPE__configured() (where FSTYPE is one of sysfs, procfs, debugfs, tracefs) interface that returns bool state of the filesystem mount:

true - mounted, false - not mounted

It will not try to mount the filesystem.

---
 tools/lib/api/fs/fs.c | 23 ++++++++++++++---------
 tools/lib/api/fs/fs.h |  5 ++++-
 2 files changed, 18 insertions(+), 10 deletions(-)
tools/lib/api/fs/fs.c +14 -9
index bc93baf..8afe08a 100644
@@ -244,15 +244,20 @@ static const char *fs__mount(int idx)
 	return fs__check_mounts(fs) ? fs->path : NULL;
 }
 
-#define FS(name, idx)			\
-const char *name##__mountpoint(void)	\
-{					\
-	return fs__mountpoint(idx);	\
-}					\
-					\
-const char *name##__mount(void)		\
-{					\
-	return fs__mount(idx);		\
+#define FS(name, idx)				\
+const char *name##__mountpoint(void)		\
+{						\
+	return fs__mountpoint(idx);		\
+}						\
+						\
+const char *name##__mount(void)			\
+{						\
+	return fs__mount(idx);			\
+}						\
+						\
+bool name##__configured(void)			\
+{						\
+	return name##__mountpoint() != NULL;	\
 }
 
 FS(sysfs,   FS__SYSFS);
tools/lib/api/fs/fs.h +4 -1
index a9627ea..f654bcb 100644
@@ -1,6 +1,8 @@
 #ifndef __API_FS__
 #define __API_FS__
 
+#include <stdbool.h>
+
 /*
  * On most systems <limits.h> would have given us this, but  not on some systems
  * (e.g. GNU/Hurd).
@@ -11,7 +13,8 @@
 
 #define FS(name)				\
 	const char *name##__mountpoint(void);	\
-	const char *name##__mount(void);
+	const char *name##__mount(void);	\
+	bool name##__configured(void);		\
 
 FS(sysfs)
 FS(procfs)
author reviewer
#51 lore raw

PATCH 13/15 tools lib api: Replace debugfs/tracefs objects interface with fs.c

In reply to Jiri Olsa

Switching to the fs.c related filesystem framework.

---
 tools/lib/api/fs/fs.c                      |  1 -
 tools/lib/api/fs/tracing_path.c            | 15 +++++++--------
 tools/perf/builtin-kvm.c                   |  1 -
 tools/perf/builtin-probe.c                 |  1 -
 tools/perf/tests/openat-syscall-all-cpus.c |  5 +++--
 tools/perf/tests/openat-syscall.c          |  5 +++--
 tools/perf/tests/parse-events.c            |  7 +++----
 tools/perf/util/evsel.c                    |  2 +-
 tools/perf/util/probe-event.c              |  5 ++---
 tools/perf/util/probe-file.c               |  7 +++----
 tools/perf/util/util.h                     |  3 +--
 11 files changed, 23 insertions(+), 29 deletions(-)
tools/lib/api/fs/fs.c +0 -1
index 8afe08a99bc6..791509346178 100644
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include <sys/mount.h>
 
-#include "debugfs.h"
 #include "fs.h"
 
 #define _STR(x) #x
tools/lib/api/fs/tracing_path.c +7 -8
index b0ee3b3acef0..b53aa9c8d1c8 100644
@@ -7,8 +7,7 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
-#include "debugfs.h"
-#include "tracefs.h"
+#include "fs.h"
 
 #include "tracing_path.h"
 
@@ -29,7 +28,7 @@ static const char *tracing_path_tracefs_mount(void)
 {
 	const char *mnt;
 
-	mnt = tracefs_mount(NULL);
+	mnt = tracefs__mount();
 	if (!mnt)
 		return NULL;
 
@@ -42,7 +41,7 @@ static const char *tracing_path_debugfs_mount(void)
 {
 	const char *mnt;
 
-	mnt = debugfs_mount(NULL);
+	mnt = debugfs__mount();
 	if (!mnt)
 		return NULL;
 
@@ -90,7 +89,7 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 
 	switch (err) {
 	case ENOENT:
-		if (debugfs_configured() || tracefs_configured()) {
+		if (debugfs__configured() || tracefs__configured()) {
 			snprintf(buf, size,
 				 "Error:\tFile %s/%s not found.\n"
 				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
@@ -104,13 +103,13 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
 		break;
 	case EACCES: {
-		const char *mountpoint = debugfs_find_mountpoint();
+		const char *mountpoint = debugfs__mountpoint();
 
 		if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
-			const char *tracefs_mntpoint = tracefs_find_mountpoint();
+			const char *tracefs_mntpoint = tracefs__mountpoint();
 
 			if (tracefs_mntpoint)
-				mountpoint = tracefs_find_mountpoint();
+				mountpoint = tracefs__mountpoint();
 		}
 
 		snprintf(buf, size,
tools/perf/builtin-kvm.c +0 -1
index fc1cffb1b7a2..dd94b4ca2213 100644
@@ -13,7 +13,6 @@
 #include "util/parse-options.h"
 #include "util/trace-event.h"
 #include "util/debug.h"
-#include <api/fs/debugfs.h>
 #include "util/tool.h"
 #include "util/stat.h"
 #include "util/top.h"
tools/perf/builtin-probe.c +0 -1
index b81cec33b4b2..310aba2756a8 100644
@@ -37,7 +37,6 @@
 #include "util/strfilter.h"
 #include "util/symbol.h"
 #include "util/debug.h"
-#include <api/fs/debugfs.h>
 #include "util/parse-options.h"
 #include "util/probe-finder.h"
 #include "util/probe-event.h"
tools/perf/tests/openat-syscall-all-cpus.c +3 -2
index a572f87e9c8d..a38adf94c731 100644
@@ -1,3 +1,4 @@
+#include <api/fs/fs.h>
 #include "evsel.h"
 #include "tests.h"
 #include "thread_map.h"
@@ -30,9 +31,9 @@ int test__openat_syscall_event_on_all_cpus(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
 	if (evsel == NULL) {
-		if (tracefs_configured())
+		if (tracefs__configured())
 			pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
-		else if (debugfs_configured())
+		else if (debugfs__configured())
 			pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
 		else
 			pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
tools/perf/tests/openat-syscall.c +3 -2
index c9a37bc6b33a..8048c7d7cd67 100644
@@ -1,3 +1,4 @@
+#include <api/fs/fs.h>
 #include "thread_map.h"
 #include "evsel.h"
 #include "debug.h"
@@ -18,9 +19,9 @@ int test__openat_syscall_event(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
 	if (evsel == NULL) {
-		if (tracefs_configured())
+		if (tracefs__configured())
 			pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
-		else if (debugfs_configured())
+		else if (debugfs__configured())
 			pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
 		else
 			pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
tools/perf/tests/parse-events.c +3 -4
index 9b6b2b6324a1..91fbfd593c4a 100644
@@ -3,11 +3,10 @@
 #include "evsel.h"
 #include "evlist.h"
 #include <api/fs/fs.h>
-#include <api/fs/tracefs.h>
-#include <api/fs/debugfs.h>
 #include "tests.h"
 #include "debug.h"
 #include <linux/hw_breakpoint.h>
+#include <api/fs/fs.h>
 
 #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
 			     PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
@@ -1268,12 +1267,12 @@ static int count_tracepoints(void)
 	DIR *events_dir;
 	int cnt = 0;
 
-	mountpoint = tracefs_find_mountpoint();
+	mountpoint = tracefs__mountpoint();
 	if (mountpoint) {
 		scnprintf(events_path, PATH_MAX, "%s/events",
 			  mountpoint);
 	} else {
-		mountpoint = debugfs_find_mountpoint();
+		mountpoint = debugfs__mountpoint();
 		scnprintf(events_path, PATH_MAX, "%s/tracing/events",
 			  mountpoint);
 	}
tools/perf/util/evsel.c +1 -1
index c53f79123b37..771ade4d5966 100644
@@ -9,7 +9,7 @@
 
 #include <byteswap.h>
 #include <linux/bitops.h>
-#include <api/fs/debugfs.h>
+#include <api/fs/tracing_path.h>
 #include <traceevent/event-parse.h>
 #include <linux/hw_breakpoint.h>
 #include <linux/perf_event.h>
tools/perf/util/probe-event.c +2 -3
index eb5f18b75402..1104c584e3d9 100644
@@ -40,8 +40,7 @@
 #include "color.h"
 #include "symbol.h"
 #include "thread.h"
-#include <api/fs/debugfs.h>
-#include <api/fs/tracefs.h>
+#include <api/fs/fs.h>
 #include "trace-event.h"	/* For __maybe_unused */
 #include "probe-event.h"
 #include "probe-finder.h"
@@ -2054,7 +2053,7 @@ static void kprobe_blacklist__delete(struct list_head *blacklist)
 static int kprobe_blacklist__load(struct list_head *blacklist)
 {
 	struct kprobe_blacklist_node *node;
-	const char *__debugfs = debugfs_find_mountpoint();
+	const char *__debugfs = debugfs__mountpoint();
 	char buf[PATH_MAX], *p;
 	FILE *fp;
 	int ret;
tools/perf/util/probe-file.c +3 -4
index bbb243717ec8..de0df1e6222a 100644
@@ -22,8 +22,7 @@
 #include "color.h"
 #include "symbol.h"
 #include "thread.h"
-#include <api/fs/debugfs.h>
-#include <api/fs/tracefs.h>
+#include <api/fs/fs.h>
 #include "probe-event.h"
 #include "probe-file.h"
 #include "session.h"
@@ -77,11 +76,11 @@ static int open_probe_events(const char *trace_file, bool readwrite)
 	const char *tracing_dir = "";
 	int ret;
 
-	__debugfs = tracefs_find_mountpoint();
+	__debugfs = tracefs__mountpoint();
 	if (__debugfs == NULL) {
 		tracing_dir = "tracing/";
 
-		__debugfs = debugfs_find_mountpoint();
+		__debugfs = debugfs__mountpoint();
 		if (__debugfs == NULL)
 			return -ENOTSUP;
 	}
tools/perf/util/util.h +1 -2
index f9a9717d2aff..91b3bb79a4b5 100644
@@ -74,8 +74,7 @@
 #include <linux/magic.h>
 #include <linux/types.h>
 #include <sys/ttydefaults.h>
-#include <api/fs/debugfs.h>
-#include <api/fs/tracefs.h>
+#include <api/fs/tracing_path.h>
 #include <termios.h>
 #include <linux/bitops.h>
 #include <termios.h>
Signature · 1 line
2.4.3
#52 lore raw

[tip:perf/core] tools lib api fs: Replace debugfs/ tracefs objects interface with fs.c

tools lib api fs: Replace debugfs/tracefs objects interface with fs.c
Commit-ID:  4605eab3487dc818b1f3cbee2cd139cca3564be7
Gitweb:     http://git.kernel.org/tip/4605eab3487dc818b1f3cbee2cd139cca3564be7
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:43 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:15 -0300

tools lib api fs: Replace debugfs/tracefs objects interface with fs.c

Switching to the fs.c related filesystem framework.

---
 tools/lib/api/fs/fs.c                      |  1 -
 tools/lib/api/fs/tracing_path.c            | 15 +++++++--------
 tools/perf/builtin-kvm.c                   |  1 -
 tools/perf/builtin-probe.c                 |  1 -
 tools/perf/tests/openat-syscall-all-cpus.c |  5 +++--
 tools/perf/tests/openat-syscall.c          |  5 +++--
 tools/perf/tests/parse-events.c            |  7 +++----
 tools/perf/util/evsel.c                    |  2 +-
 tools/perf/util/probe-event.c              |  5 ++---
 tools/perf/util/probe-file.c               |  7 +++----
 tools/perf/util/util.h                     |  3 +--
 11 files changed, 23 insertions(+), 29 deletions(-)
tools/lib/api/fs/fs.c +0 -1
index 8afe08a..7915093 100644
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include <sys/mount.h>
 
-#include "debugfs.h"
 #include "fs.h"
 
 #define _STR(x) #x
tools/lib/api/fs/tracing_path.c +7 -8
index 1e0bb0d..38aca2d 100644
@@ -7,8 +7,7 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
-#include "debugfs.h"
-#include "tracefs.h"
+#include "fs.h"
 
 #include "tracing_path.h"
 
@@ -29,7 +28,7 @@ static const char *tracing_path_tracefs_mount(void)
 {
 	const char *mnt;
 
-	mnt = tracefs_mount(NULL);
+	mnt = tracefs__mount();
 	if (!mnt)
 		return NULL;
 
@@ -42,7 +41,7 @@ static const char *tracing_path_debugfs_mount(void)
 {
 	const char *mnt;
 
-	mnt = debugfs_mount(NULL);
+	mnt = debugfs__mount();
 	if (!mnt)
 		return NULL;
 
@@ -96,7 +95,7 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 		 * want some tracepoint which wasn't compiled in your kernel.
 		 * - jirka
 		 */
-		if (debugfs_configured() || tracefs_configured()) {
+		if (debugfs__configured() || tracefs__configured()) {
 			snprintf(buf, size,
 				 "Error:\tFile %s/%s not found.\n"
 				 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
@@ -110,13 +109,13 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
 			 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
 		break;
 	case EACCES: {
-		const char *mountpoint = debugfs_find_mountpoint();
+		const char *mountpoint = debugfs__mountpoint();
 
 		if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
-			const char *tracefs_mntpoint = tracefs_find_mountpoint();
+			const char *tracefs_mntpoint = tracefs__mountpoint();
 
 			if (tracefs_mntpoint)
-				mountpoint = tracefs_find_mountpoint();
+				mountpoint = tracefs__mountpoint();
 		}
 
 		snprintf(buf, size,
tools/perf/builtin-kvm.c +0 -1
index fc1cffb..dd94b4c 100644
@@ -13,7 +13,6 @@
 #include "util/parse-options.h"
 #include "util/trace-event.h"
 #include "util/debug.h"
-#include <api/fs/debugfs.h>
 #include "util/tool.h"
 #include "util/stat.h"
 #include "util/top.h"
tools/perf/builtin-probe.c +0 -1
index ee2c46d..2bec9c1 100644
@@ -37,7 +37,6 @@
 #include "util/strfilter.h"
 #include "util/symbol.h"
 #include "util/debug.h"
-#include <api/fs/debugfs.h>
 #include "util/parse-options.h"
 #include "util/probe-finder.h"
 #include "util/probe-event.h"
tools/perf/tests/openat-syscall-all-cpus.c +3 -2
index a572f87..a38adf9 100644
@@ -1,3 +1,4 @@
+#include <api/fs/fs.h>
 #include "evsel.h"
 #include "tests.h"
 #include "thread_map.h"
@@ -30,9 +31,9 @@ int test__openat_syscall_event_on_all_cpus(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
 	if (evsel == NULL) {
-		if (tracefs_configured())
+		if (tracefs__configured())
 			pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
-		else if (debugfs_configured())
+		else if (debugfs__configured())
 			pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
 		else
 			pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
tools/perf/tests/openat-syscall.c +3 -2
index c9a37bc..8048c7d 100644
@@ -1,3 +1,4 @@
+#include <api/fs/fs.h>
 #include "thread_map.h"
 #include "evsel.h"
 #include "debug.h"
@@ -18,9 +19,9 @@ int test__openat_syscall_event(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
 	if (evsel == NULL) {
-		if (tracefs_configured())
+		if (tracefs__configured())
 			pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
-		else if (debugfs_configured())
+		else if (debugfs__configured())
 			pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
 		else
 			pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
tools/perf/tests/parse-events.c +3 -4
index 9b6b2b63..91fbfd5 100644
@@ -3,11 +3,10 @@
 #include "evsel.h"
 #include "evlist.h"
 #include <api/fs/fs.h>
-#include <api/fs/tracefs.h>
-#include <api/fs/debugfs.h>
 #include "tests.h"
 #include "debug.h"
 #include <linux/hw_breakpoint.h>
+#include <api/fs/fs.h>
 
 #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
 			     PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
@@ -1268,12 +1267,12 @@ static int count_tracepoints(void)
 	DIR *events_dir;
 	int cnt = 0;
 
-	mountpoint = tracefs_find_mountpoint();
+	mountpoint = tracefs__mountpoint();
 	if (mountpoint) {
 		scnprintf(events_path, PATH_MAX, "%s/events",
 			  mountpoint);
 	} else {
-		mountpoint = debugfs_find_mountpoint();
+		mountpoint = debugfs__mountpoint();
 		scnprintf(events_path, PATH_MAX, "%s/tracing/events",
 			  mountpoint);
 	}
tools/perf/util/evsel.c +1 -1
index c53f791..771ade4 100644
@@ -9,7 +9,7 @@
 
 #include <byteswap.h>
 #include <linux/bitops.h>
-#include <api/fs/debugfs.h>
+#include <api/fs/tracing_path.h>
 #include <traceevent/event-parse.h>
 #include <linux/hw_breakpoint.h>
 #include <linux/perf_event.h>
tools/perf/util/probe-event.c +2 -3
index 3da9e1c..5964ecc 100644
@@ -40,8 +40,7 @@
 #include "color.h"
 #include "symbol.h"
 #include "thread.h"
-#include <api/fs/debugfs.h>
-#include <api/fs/tracefs.h>
+#include <api/fs/fs.h>
 #include "trace-event.h"	/* For __maybe_unused */
 #include "probe-event.h"
 #include "probe-finder.h"
@@ -2054,7 +2053,7 @@ static void kprobe_blacklist__delete(struct list_head *blacklist)
 static int kprobe_blacklist__load(struct list_head *blacklist)
 {
 	struct kprobe_blacklist_node *node;
-	const char *__debugfs = debugfs_find_mountpoint();
+	const char *__debugfs = debugfs__mountpoint();
 	char buf[PATH_MAX], *p;
 	FILE *fp;
 	int ret;
tools/perf/util/probe-file.c +3 -4
index 38c0a62..499c83c 100644
@@ -22,8 +22,7 @@
 #include "color.h"
 #include "symbol.h"
 #include "thread.h"
-#include <api/fs/debugfs.h>
-#include <api/fs/tracefs.h>
+#include <api/fs/fs.h>
 #include "probe-event.h"
 #include "probe-file.h"
 #include "session.h"
@@ -77,11 +76,11 @@ static int open_probe_events(const char *trace_file, bool readwrite)
 	const char *tracing_dir = "";
 	int ret;
 
-	__debugfs = tracefs_find_mountpoint();
+	__debugfs = tracefs__mountpoint();
 	if (__debugfs == NULL) {
 		tracing_dir = "tracing/";
 
-		__debugfs = debugfs_find_mountpoint();
+		__debugfs = debugfs__mountpoint();
 		if (__debugfs == NULL)
 			return -ENOTSUP;
 	}
tools/perf/util/util.h +1 -2
index 495b99c..3d5b01e 100644
@@ -74,8 +74,7 @@
 #include <linux/magic.h>
 #include <linux/types.h>
 #include <sys/ttydefaults.h>
-#include <api/fs/debugfs.h>
-#include <api/fs/tracefs.h>
+#include <api/fs/tracing_path.h>
 #include <termios.h>
 #include <linux/bitops.h>
 #include <termios.h>
author reviewer
#53 lore raw

PATCH 14/15 tools lib api: Remove debugfs, tracefs and findfs objects

In reply to Jiri Olsa

We have all the functionality in fs.c, let's remove unneeded objects.

---
 tools/lib/api/fs/Build     |  3 --
 tools/lib/api/fs/debugfs.c | 77 ---------------------------------------------
 tools/lib/api/fs/debugfs.h | 23 --------------
 tools/lib/api/fs/findfs.c  | 63 -------------------------------------
 tools/lib/api/fs/findfs.h  | 23 --------------
 tools/lib/api/fs/tracefs.c | 78 ----------------------------------------------
 tools/lib/api/fs/tracefs.h | 21 -------------
 7 files changed, 288 deletions(-)
 delete mode 100644 tools/lib/api/fs/debugfs.c
 delete mode 100644 tools/lib/api/fs/debugfs.h
 delete mode 100644 tools/lib/api/fs/findfs.c
 delete mode 100644 tools/lib/api/fs/findfs.h
 delete mode 100644 tools/lib/api/fs/tracefs.c
 delete mode 100644 tools/lib/api/fs/tracefs.h
tools/lib/api/fs/Build +0 -3
index fa726f679b29..f4ed9629ae85 100644
@@ -1,5 +1,2 @@
 libapi-y += fs.o
 libapi-y += tracing_path.o
-libapi-y += debugfs.o
-libapi-y += findfs.o
-libapi-y += tracefs.o
tools/lib/api/fs/debugfs.c deleted +0 -77

77 lines not on this page · raw message

tools/lib/api/fs/debugfs.h deleted +0 -23
deleted file mode 100644
index 455023698d2b..000000000000
@@ -1,23 +0,0 @@
-#ifndef __API_DEBUGFS_H__
-#define __API_DEBUGFS_H__
-
-#include "findfs.h"
-
-#ifndef DEBUGFS_MAGIC
-#define DEBUGFS_MAGIC          0x64626720
-#endif
-
-#ifndef PERF_DEBUGFS_ENVIRONMENT
-#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
-#endif
-
-bool debugfs_configured(void);
-const char *debugfs_find_mountpoint(void);
-char *debugfs_mount(const char *mountpoint);
-
-extern char debugfs_mountpoint[];
-
-int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename);
-int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);
-
-#endif /* __API_DEBUGFS_H__ */
tools/lib/api/fs/findfs.c deleted +0 -63

63 lines not on this page · raw message

tools/lib/api/fs/findfs.h deleted +0 -23
deleted file mode 100644
index b6f5d05acc42..000000000000
@@ -1,23 +0,0 @@
-#ifndef __API_FINDFS_H__
-#define __API_FINDFS_H__
-
-#include <stdbool.h>
-
-#define _STR(x) #x
-#define STR(x) _STR(x)
-
-/*
- * On most systems <limits.h> would have given us this, but  not on some systems
- * (e.g. GNU/Hurd).
- */
-#ifndef PATH_MAX
-#define PATH_MAX 4096
-#endif
-
-const char *find_mountpoint(const char *fstype, long magic,
-			    char *mountpoint, int len,
-			    const char * const *known_mountpoints);
-
-int valid_mountpoint(const char *mount, long magic);
-
-#endif /* __API_FINDFS_H__ */
tools/lib/api/fs/tracefs.c deleted +0 -78

78 lines not on this page · raw message

tools/lib/api/fs/tracefs.h deleted +0 -21
deleted file mode 100644
index da780ac49acb..000000000000
@@ -1,21 +0,0 @@
-#ifndef __API_TRACEFS_H__
-#define __API_TRACEFS_H__
-
-#include "findfs.h"
-
-#ifndef TRACEFS_MAGIC
-#define TRACEFS_MAGIC          0x74726163
-#endif
-
-#ifndef PERF_TRACEFS_ENVIRONMENT
-#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
-#endif
-
-bool tracefs_configured(void);
-const char *tracefs_find_mountpoint(void);
-int tracefs_valid_mountpoint(const char *debugfs);
-char *tracefs_mount(const char *mountpoint);
-
-extern char tracefs_mountpoint[];
-
-#endif /* __API_DEBUGFS_H__ */
Signature · 1 line
2.4.3
#54 lore raw

[tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

tools lib api fs: Remove debugfs, tracefs and findfs objects
Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:15 -0300

tools lib api fs: Remove debugfs, tracefs and findfs objects

We have all the functionality in fs.c, let's remove unneeded objects.

---
 tools/lib/api/fs/Build     |  3 --
 tools/lib/api/fs/debugfs.c | 77 ---------------------------------------------
 tools/lib/api/fs/debugfs.h | 23 --------------
 tools/lib/api/fs/findfs.c  | 63 -------------------------------------
 tools/lib/api/fs/findfs.h  | 23 --------------
 tools/lib/api/fs/tracefs.c | 78 ----------------------------------------------
 tools/lib/api/fs/tracefs.h | 21 -------------
 7 files changed, 288 deletions(-)
tools/lib/api/fs/Build +0 -3
index fa726f6..f4ed962 100644
@@ -1,5 +1,2 @@
 libapi-y += fs.o
 libapi-y += tracing_path.o
-libapi-y += debugfs.o
-libapi-y += findfs.o
-libapi-y += tracefs.o
tools/lib/api/fs/debugfs.c deleted +0 -77

77 lines not on this page · raw message

tools/lib/api/fs/debugfs.h deleted +0 -23
deleted file mode 100644
index 4550236..0000000
@@ -1,23 +0,0 @@
-#ifndef __API_DEBUGFS_H__
-#define __API_DEBUGFS_H__
-
-#include "findfs.h"
-
-#ifndef DEBUGFS_MAGIC
-#define DEBUGFS_MAGIC          0x64626720
-#endif
-
-#ifndef PERF_DEBUGFS_ENVIRONMENT
-#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
-#endif
-
-bool debugfs_configured(void);
-const char *debugfs_find_mountpoint(void);
-char *debugfs_mount(const char *mountpoint);
-
-extern char debugfs_mountpoint[];
-
-int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename);
-int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);
-
-#endif /* __API_DEBUGFS_H__ */
tools/lib/api/fs/findfs.c deleted +0 -63

63 lines not on this page · raw message

tools/lib/api/fs/findfs.h deleted +0 -23
deleted file mode 100644
index b6f5d05..0000000
@@ -1,23 +0,0 @@
-#ifndef __API_FINDFS_H__
-#define __API_FINDFS_H__
-
-#include <stdbool.h>
-
-#define _STR(x) #x
-#define STR(x) _STR(x)
-
-/*
- * On most systems <limits.h> would have given us this, but  not on some systems
- * (e.g. GNU/Hurd).
- */
-#ifndef PATH_MAX
-#define PATH_MAX 4096
-#endif
-
-const char *find_mountpoint(const char *fstype, long magic,
-			    char *mountpoint, int len,
-			    const char * const *known_mountpoints);
-
-int valid_mountpoint(const char *mount, long magic);
-
-#endif /* __API_FINDFS_H__ */
tools/lib/api/fs/tracefs.c deleted +0 -78

78 lines not on this page · raw message

tools/lib/api/fs/tracefs.h deleted +0 -21
deleted file mode 100644
index da780ac..0000000
@@ -1,21 +0,0 @@
-#ifndef __API_TRACEFS_H__
-#define __API_TRACEFS_H__
-
-#include "findfs.h"
-
-#ifndef TRACEFS_MAGIC
-#define TRACEFS_MAGIC          0x74726163
-#endif
-
-#ifndef PERF_TRACEFS_ENVIRONMENT
-#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
-#endif
-
-bool tracefs_configured(void);
-const char *tracefs_find_mountpoint(void);
-int tracefs_valid_mountpoint(const char *debugfs);
-char *tracefs_mount(const char *mountpoint);
-
-extern char tracefs_mountpoint[];
-
-#endif /* __API_DEBUGFS_H__ */
#55 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

Quoted 12 lines · tip-bot for Jiri Olsa
Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:15 -0300

tools lib api fs: Remove debugfs, tracefs and findfs objects

We have all the functionality in fs.c, let's remove unneeded objects.

Quoted 9 lines

Hi.

This commit seems to have introduced a build failure with tools/vm.

$ make -C tools vm
[...]
gcc -Wall -Wextra -I../lib/ -o page-types page-types.c ../lib/api/libapi.a
page-types.c:45:28: fatal error: api/fs/debugfs.h: No such file or directory
 #include <api/fs/debugfs.h>
                            ^

Cheers,
Vinson

#56 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

Em Mon, Sep 21, 2015 at 05:20:03PM -0700, Vinson Lee escreveu:

Quoted 26 lines
Quoted 12 lines · tip-bot for Jiri Olsa
Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:15 -0300

tools lib api fs: Remove debugfs, tracefs and findfs objects

We have all the functionality in fs.c, let's remove unneeded objects.

Quoted 9 lines

Hi.

Quoted 7 lines

This commit seems to have introduced a build failure with tools/vm.

$ make -C tools vm
[...]
gcc -Wall -Wextra -I../lib/ -o page-types page-types.c ../lib/api/libapi.a
page-types.c:45:28: fatal error: api/fs/debugfs.h: No such file or directory
 #include <api/fs/debugfs.h>

Can you please check if this solves the problem?

- Arnaldo

tools/vm/page-types.c +3 -3
index 7f73fa32a590..bcf5ec760eb9 100644
@@ -42,7 +42,7 @@
 #include <sys/mman.h>
 #include "../../include/uapi/linux/magic.h"
 #include "../../include/uapi/linux/kernel-page-flags.h"
-#include <api/fs/debugfs.h>
+#include <api/fs/fs.h>
 
 #ifndef MAX_PATH
 # define MAX_PATH 256
@@ -188,7 +188,7 @@ static int		kpageflags_fd;
 static int		opt_hwpoison;
 static int		opt_unpoison;
 
-static char		*hwpoison_debug_fs;
+static const char	*hwpoison_debug_fs;
 static int		hwpoison_inject_fd;
 static int		hwpoison_forget_fd;
 
@@ -487,7 +487,7 @@ static void prepare_hwpoison_fd(void)
 {
 	char buf[MAX_PATH + 1];
 
-	hwpoison_debug_fs = debugfs_mount(NULL);
+	hwpoison_debug_fs = debugfs__mount();
 	if (!hwpoison_debug_fs) {
 		perror("mount debugfs");
 		exit(EXIT_FAILURE);
#57 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

Quoted 62 lines · Arnaldo Carvalho de Melo

Em Mon, Sep 21, 2015 at 05:20:03PM -0700, Vinson Lee escreveu:

Quoted 26 lines
Quoted 12 lines · tip-bot for Jiri Olsa
Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:15 -0300

tools lib api fs: Remove debugfs, tracefs and findfs objects

We have all the functionality in fs.c, let's remove unneeded objects.

Quoted 9 lines

Hi.

Quoted 7 lines

This commit seems to have introduced a build failure with tools/vm.

$ make -C tools vm
[...]
gcc -Wall -Wextra -I../lib/ -o page-types page-types.c ../lib/api/libapi.a
page-types.c:45:28: fatal error: api/fs/debugfs.h: No such file or directory
 #include <api/fs/debugfs.h>

Can you please check if this solves the problem?

- Arnaldo

tools/vm/page-types.c +2 -2
index 7f73fa32a590..bcf5ec760eb9 100644
@@ -42,7 +42,7 @@
 #include <sys/mman.h>
 #include "../../include/uapi/linux/magic.h"
 #include "../../include/uapi/linux/kernel-page-flags.h"
-#include <api/fs/debugfs.h>
+#include <api/fs/fs.h>
 
 #ifndef MAX_PATH
 # define MAX_PATH 256
@@ -188,7 +188,7 @@ static int          kpageflags_fd;
 static int             opt_hwpoison;
 static int             opt_unpoison;
 
-static char            *hwpoison_debug_fs;
+static const char      *hwpoison_debug_fs;
 static int             hwpoison_inject_fd;
 static int             hwpoison_forget_fd;
 

tools/vm/page-types.c static void prepare_hwpoison_fd(void) · line 493

Quoted 8 lines
tools/vm/page-types.c +1 -1
@@ -487,7 +487,7 @@ static void prepare_hwpoison_fd(void)
 {
        char buf[MAX_PATH + 1];
 
-       hwpoison_debug_fs = debugfs_mount(NULL);
+       hwpoison_debug_fs = debugfs__mount();
        if (!hwpoison_debug_fs) {
                perror("mount debugfs");
                exit(EXIT_FAILURE);

Yes, this patch fixes the build for me.

Vinson

#58 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

In reply to Vinson Lee
Quoted 26 lines · Vinson Lee
Quoted 12 lines · tip-bot for Jiri Olsa
Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:15 -0300

tools lib api fs: Remove debugfs, tracefs and findfs objects

We have all the functionality in fs.c, let's remove unneeded objects.

Quoted 9 lines

Hi.

Quoted 7 lines

This commit seems to have introduced a build failure with tools/vm.

$ make -C tools vm
[...]
gcc -Wall -Wextra -I../lib/ -o page-types page-types.c ../lib/api/libapi.a
page-types.c:45:28: fatal error: api/fs/debugfs.h: No such file or directory
 #include <api/fs/debugfs.h>

Given the ferocious pace of development of tools/perf, is there not some kind of automated build that happens when new patches are picked up, before they're pushed out?

Things are refactored and changed so fast in this area (I dare say faster than almost any other part of the kernel source tree) that not having the safety net of automated builds just seems suicidal.

And that doesn't even begin to cover runtime testing, since I've noticed things breaking in tools/perf and people not catching it immediately.

Does automated testing exist for perf tools development?

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#59 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

Quoted 43 lines · Matt Fleming
Quoted 26 lines · Vinson Lee
Quoted 12 lines · tip-bot for Jiri Olsa
Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:15 -0300

tools lib api fs: Remove debugfs, tracefs and findfs objects

We have all the functionality in fs.c, let's remove unneeded objects.

Quoted 9 lines

Hi.

Quoted 7 lines

This commit seems to have introduced a build failure with tools/vm.

$ make -C tools vm
[...]
gcc -Wall -Wextra -I../lib/ -o page-types page-types.c ../lib/api/libapi.a
page-types.c:45:28: fatal error: api/fs/debugfs.h: No such file or directory
 #include <api/fs/debugfs.h>

Given the ferocious pace of development of tools/perf, is there not some kind of automated build that happens when new patches are picked up, before they're pushed out?

Things are refactored and changed so fast in this area (I dare say faster than almost any other part of the kernel source tree) that not having the safety net of automated builds just seems suicidal.

Quoted 5 lines

And that doesn't even begin to cover runtime testing, since I've noticed things breaking in tools/perf and people not catching it immediately.

Does automated testing exist for perf tools development?

heh, we've been playing game "who first mention it in public will implement it" ... you won! ;-)

AFAIK we have:
- 'perf test' for perf specific functionality
- 'make -f tests/make' for building
- build framework tests

I 'try' to run those before sending anything out, but we dont have automated thing that would run it any time Arnaldo push new perf/core.

The RedHat QE has some more perf tool tests. There was some movement to make those public, but not sure how it ended up.. ccing Michael Petlan for news on this ;-)

jirka

#60 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

Quoted 5 lines · Jiri Olsa
Quoted 2 lines · Matt Fleming

Does automated testing exist for perf tools development?

heh, we've been playing game "who first mention it in public will implement it" ... you won! ;-)

Hehe, whoops!

Quoted 7 lines

AFAIK we have:
- 'perf test' for perf specific functionality
- 'make -f tests/make' for building
- build framework tests

I 'try' to run those before sending anything out, but we dont have automated thing that would run it any time Arnaldo push new perf/core.

Right. The problem with manual steps is that they're easy to forget. Furthermore, it actively discourages you from adding new testing functionality that requires more manual steps (who wants to remember to type another command?).

Yes, you can script it, but then every developer ends up with their own version, which get out of sync, or work slightly differently etc.

Also, now that we've potentially got perf arch tests coming [1] you or Arnaldo may not always have the hardware available to ensure that no regressions were introduced to the runtime testing, or the OS installations to perform build testing, for say, Ubuntu or OpenSUSE.

That is kind of a separate problem (automated testing of a matrix of OS and hardware configs), but having a single, standard way to automate build/runtime testing of tools/perf is the first step.

Quoted 3 lines

The RedHat QE has some more perf tool tests. There was some movement to make those public, but not sure how it ended up.. ccing Michael Petlan for news on this ;-)

Cool! I'd definitely be interested in knowing the details.

[1] - https://lkml.kernel.org/r/[email protected]

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#61 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

On Wed, 2015-09-23 at 11:08 +0100, Matt Fleming wrote:

[SNIP]

Quoted 6 lines
Quoted 3 lines

The RedHat QE has some more perf tool tests. There was some movement to make those public, but not sure how it ended up.. ccing Michael Petlan for news on this ;-)

Cool! I'd definitely be interested in knowing the details.

Hi!

Yes, we have some tests, but they really need some refactoring and then extending.

There are many "regression" tests that cover some extreme situations that failed with some kernel/perf version on some hardware. They are probably not very useful for the purpose mentioned here.

Then there are some tests that should cover basic functionality and check for the correctness of perf's behaviour. Since it became being pretty messy, I have got an idea to rewrite that in a more structured and robust way and make it public.

So I started with some skeleton and tests for perf stat builtin sub command [1]. My idea is to port there all the meaningful tests that we have at Red Hat. Then I will be happy if someone else is interested in contributing some more coverage, ideas or whatever...

I am on a PTO for two weeks from now, so I will respond after it, if you have any questions, suggestions or ideas.

Regards,
Michael

[1] https://github.com/rfmvh/perftool-testsuite

#62 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

Quoted 9 lines · Michael Petlan

Hi!

Yes, we have some tests, but they really need some refactoring and then extending.

There are many "regression" tests that cover some extreme situations that failed with some kernel/perf version on some hardware. They are probably not very useful for the purpose mentioned here.

If they look anything like this,

https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=035827e9f2bd71a280f4eb58c65811d377ab2217

i.e. the tests trigger kernel bugs, then I think they would be useful. If the tests are more along the lines of "you need a huge machine to trigger the issue caught by the test", maybe not.

Quoted 4 lines

Then there are some tests that should cover basic functionality and check for the correctness of perf's behaviour. Since it became being pretty messy, I have got an idea to rewrite that in a more structured and robust way and make it public.

These tests sounds incredibly useful. I would certainly feel better if I could just hack on random pieces of tools/perf and have the safety net of regression tests to catch mistakes.

Quoted 4 lines

So I started with some skeleton and tests for perf stat builtin sub command [1]. My idea is to port there all the meaningful tests that we have at Red Hat. Then I will be happy if someone else is interested in contributing some more coverage, ideas or whatever...

My immediate reaction is: please put these tests into tools/perf, do not create a separate repository.

Now, you've probably got a good reason for wanting to do that, but definitely let's discuss it first before you go ahead and invest time and energy in porting things.

You can see my current line of thinking for perf testing with the perf arch tests series,

https://lkml.kernel.org/r/[email protected]

I think tools/perf as a concenpt (include the userland tool in the same repo as the kernel) has been very successful because you frequently get the same developer writing both the userspace and kernel code. Extending that so the same developer writes the regression tests too (at the time they introduce their new code!) is crucial.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#63 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

Em Wed, Oct 07, 2015 at 09:10:30PM +0100, Matt Fleming escreveu:

Quoted 28 lines · Michael Petlan
Quoted 9 lines

Hi!

Yes, we have some tests, but they really need some refactoring and then extending.

There are many "regression" tests that cover some extreme situations that failed with some kernel/perf version on some hardware. They are probably not very useful for the purpose mentioned here.

If they look anything like this,

https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=035827e9f2bd71a280f4eb58c65811d377ab2217

i.e. the tests trigger kernel bugs, then I think they would be useful. If the tests are more along the lines of "you need a huge machine to trigger the issue caught by the test", maybe not.

Quoted 4 lines

Then there are some tests that should cover basic functionality and check for the correctness of perf's behaviour. Since it became being pretty messy, I have got an idea to rewrite that in a more structured and robust way and make it public.

These tests sounds incredibly useful. I would certainly feel better if I could just hack on random pieces of tools/perf and have the safety net of regression tests to catch mistakes.

Quoted 7 lines
Quoted 4 lines

So I started with some skeleton and tests for perf stat builtin sub command [1]. My idea is to port there all the meaningful tests that we have at Red Hat. Then I will be happy if someone else is interested in contributing some more coverage, ideas or whatever...

My immediate reaction is: please put these tests into tools/perf, do not create a separate repository.

Right, agreed, we need to look at what we have, how a new build test is done, for instance, how those perf_event_attr tests using a python harness, etc, but more than anything, we need as many regression tests as possible, so yeah, please try to have it somehow hooked into 'perf test' and aim to have whatever tests you have ran when whoever runs 'perf test'.

- Arnaldo

Quoted 18 lines

Now, you've probably got a good reason for wanting to do that, but definitely let's discuss it first before you go ahead and invest time and energy in porting things.

You can see my current line of thinking for perf testing with the perf arch tests series,

https://lkml.kernel.org/r/[email protected]

I think tools/perf as a concenpt (include the userland tool in the same repo as the kernel) has been very successful because you frequently get the same developer writing both the userspace and kernel code. Extending that so the same developer writes the regression tests too (at the time they introduce their new code!) is crucial.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#64 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

In reply to Jiri Olsa

Em Wed, Sep 23, 2015 at 10:39:06AM +0200, Jiri Olsa escreveu:

Quoted 10 lines · Matt Fleming
Quoted 9 lines · Vinson Lee
Quoted 7 lines

This commit seems to have introduced a build failure with tools/vm.

$ make -C tools vm
[...]
gcc -Wall -Wextra -I../lib/ -o page-types page-types.c ../lib/api/libapi.a
page-types.c:45:28: fatal error: api/fs/debugfs.h: No such file or directory
 #include <api/fs/debugfs.h>
Quoted 7 lines
Quoted 7 lines

Given the ferocious pace of development of tools/perf, is there not some kind of automated build that happens when new patches are picked up, before they're pushed out?

Things are refactored and changed so fast in this area (I dare say faster than almost any other part of the kernel source tree) that not having the safety net of automated builds just seems suicidal.

Well, I don't want to die, and I work with people that would kill me if I behaved that way, so I think its not _that_ bad, there are safeguards, and we're always thinking about adding some more. 8-)

Quoted 8 lines
Quoted 5 lines

And that doesn't even begin to cover runtime testing, since I've noticed things breaking in tools/perf and people not catching it immediately.

Does automated testing exist for perf tools development?

heh, we've been playing game "who first mention it in public will implement it" ... you won! ;-)

Nah, you did lotsa already with tools/perf/tests/make

[acme@zoo linux]$ grep ^make tools/perf/tests/make
make_clean_all := clean all
make_python_perf_so := python/perf.so

make_debug          := DEBUG=1
make_no_libperl     := NO_LIBPERL=1
make_no_libpython   := NO_LIBPYTHON=1
make_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
make_no_newt        := NO_NEWT=1
make_no_slang       := NO_SLANG=1
make_no_gtk2        := NO_GTK2=1
make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_no_demangle    := NO_DEMANGLE=1
make_no_libelf      := NO_LIBELF=1
make_no_libunwind   := NO_LIBUNWIND=1
make_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1
make_no_backtrace   := NO_BACKTRACE=1
make_no_libnuma     := NO_LIBNUMA=1
make_no_libaudit    := NO_LIBAUDIT=1
make_no_libbionic   := NO_LIBBIONIC=1
make_no_auxtrace    := NO_AUXTRACE=1
make_tags           := tags
make_cscope         := cscope
make_help           := help
make_doc            := doc
make_perf_o           := perf.o
make_util_map_o       := util/map.o
make_util_pmu_bison_o := util/pmu-bison.o
make_install        := install
make_install_bin    := install-bin
make_install_doc    := install-doc
make_install_man    := install-man
make_install_html   := install-html
make_install_info   := install-info
make_install_pdf    := install-pdf
make_install_prefix       := install prefix=/tmp/krava
make_install_prefix_slash := install prefix=/tmp/krava/
make_static         := LDFLAGS=-static
make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1

NO_BACKTRACE=1
make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1
make_kernelsrc:
make_kernelsrc_tools:
[acme@zoo linux]$

This takes a lot of testing, I plan on using TypeChef to speed that up and increase the number of tests:

https://github.com/ckaestne/TypeChef-LinuxAnalysis/blob/master/README.md

And 'perf test' has 40 tests, with some being really a multiplexor, like the perf_event_attr ones, that will run the tools and look at how they set up perf_event_attr for multiple command line options:

[root@zoo ~]# perf test | tail -10

31: Test output sorting of hist entries                      : Ok
32: Test cumulation of child hist entries                    : Ok
33: Test tracking with sched_switch                          : Ok
34: Filter fds with revents mask in a fdarray                : Ok
35: Add fd to a fdarray, making it autogrow                  : Ok
36: Test kmod_path__parse function                           : Ok
37: Test thread map                                          : Ok
38: Test LLVM searching and compiling                        : (skip bpf parsing) Ok
39: Test x86 instruction decoder - new instructions          : Ok
40: Test topology in session                                 : Ok

[root@zoo ~]#

New stuff normally comes with new 'perf test' entries, Intel PT borrowed the kernel x86 instruction decoder: added a 'perf test' entry, AFAIK there was no similar test for it in the kernel proper, IIRC Masami plans to do it.

The attr one you can look at:

[acme@zoo linux]$ ls -la tools/perf/tests/attr/test-* | wc -l 33

Quoted 7 lines

AFAIK we have:
- 'perf test' for perf specific functionality
- 'make -f tests/make' for building
- build framework tests

I 'try' to run those before sending anything out, but we dont have automated thing that would run it any time Arnaldo push new perf/core.

Well, I do run it in multiple distros, like RHEL5, RHEL6 and RHEL7 besides Fedora 21.

We're getting used to tools/{lib,include}/ so this happened, but otherwise I don't feel like there are that many problems cropping up as you seem to think :-\

Of course, in these days of CI, I'd love if someone would hook 'make -C tools/perf build-test' and 'perf test' somewhere to be run for every changeset.

Quoted 3 lines

The RedHat QE has some more perf tool tests. There was some movement to make those public, but not sure how it ended up.. ccing Michael Petlan for news on this ;-)

Yeah, this too has helped catch and fix problems.

BTW, tools/vm/ was reported yesterday and a fix is already in tip/perf/core/:

https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/tools/vm?id=f6489bc2d402c0db84aa64f13b864d17f7eecb07

Age       Commit message (Expand)                                           Author                   Files Lines
12 hours  tools vm: Fix build due to removal of tools/lib/api/fs/debugfs.h  Arnaldo Carvalho de Melo	1  -3/+3

- Arnaldo

#65 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

On Wed, Sep 23, 2015 at 10:44:56AM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

Quoted 21 lines

New stuff normally comes with new 'perf test' entries, Intel PT borrowed the kernel x86 instruction decoder: added a 'perf test' entry, AFAIK there was no similar test for it in the kernel proper, IIRC Masami plans to do it.

The attr one you can look at:

[acme@zoo linux]$ ls -la tools/perf/tests/attr/test-* | wc -l 33

Quoted 7 lines

AFAIK we have:
- 'perf test' for perf specific functionality
- 'make -f tests/make' for building
- build framework tests

I 'try' to run those before sending anything out, but we dont have automated thing that would run it any time Arnaldo push new perf/core.

Well, I do run it in multiple distros, like RHEL5, RHEL6 and RHEL7 besides Fedora 21.

Quoted 7 lines

We're getting used to tools/{lib,include}/ so this happened, but otherwise I don't feel like there are that many problems cropping up as you seem to think :-\

Of course, in these days of CI, I'd love if someone would hook 'make -C tools/perf build-test' and 'perf test' somewhere to be run for every changeset.

yep, thats what I meant.. having this hooked up to your perf/core would be big help

jirka

#66 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

Em Wed, Sep 23, 2015 at 03:50:12PM +0200, Jiri Olsa escreveu:

Quoted 29 lines · Arnaldo Carvalho de Melo

SNIP

Quoted 25 lines

New stuff normally comes with new 'perf test' entries, Intel PT borrowed the kernel x86 instruction decoder: added a 'perf test' entry, AFAIK there was no similar test for it in the kernel proper, IIRC Masami plans to do it.

The attr one you can look at:

[acme@zoo linux]$ ls -la tools/perf/tests/attr/test-* | wc -l 33

Quoted 7 lines

AFAIK we have:
- 'perf test' for perf specific functionality
- 'make -f tests/make' for building
- build framework tests

I 'try' to run those before sending anything out, but we dont have automated thing that would run it any time Arnaldo push new perf/core.

Well, I do run it in multiple distros, like RHEL5, RHEL6 and RHEL7 besides Fedora 21.

We're getting used to tools/{lib,include}/ so this happened, but otherwise I don't feel like there are that many problems cropping up as you seem to think :-\

Quoted 6 lines
Quoted 3 lines

Of course, in these days of CI, I'd love if someone would hook 'make -C tools/perf build-test' and 'perf test' somewhere to be run for every changeset.

yep, thats what I meant.. having this hooked up to your perf/core would be big help

Till then, I'll turn more machines on here at my lab to do do it manually and add an entry for:

make -C tools/vm/

In that 'make -C tools/perf build-test'

- Arnaldo

#67 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

In reply to Arnaldo Carvalho de Melo
Quoted 4 lines · Arnaldo Carvalho de Melo

Of course, in these days of CI, I'd love if someone would hook 'make -C tools/perf build-test' and 'perf test' somewhere to be run for every changeset.

Yes please!

Quoted 7 lines

BTW, tools/vm/ was reported yesterday and a fix is already in tip/perf/core/:

https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/tools/vm?id=f6489bc2d402c0db84aa64f13b864d17f7eecb07

Age       Commit message (Expand)                                           Author                   Files Lines
12 hours  tools vm: Fix build due to removal of tools/lib/api/fs/debugfs.h  Arnaldo Carvalho de Melo	1  -3/+3

It's not that this wasn't fixed quickly (kudos for that, btw), rather it's that the breakage should have been avoided altogether.

But if this is an isolated incident, then fair enough, I'll stop whining.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#68 lore raw

Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects

Em Thu, Sep 24, 2015 at 01:15:51PM +0100, Matt Fleming escreveu:

Quoted 6 lines · Arnaldo Carvalho de Melo
Quoted 3 lines

Of course, in these days of CI, I'd love if someone would hook 'make -C tools/perf build-test' and 'perf test' somewhere to be run for every changeset.

Yes please!

But then even this one would have not been caught, because the test in place don't include trying to build tools/vm/, i.e. from time to time something will pass and will be caught by people like Vinson, reported and fixed :-)

Quoted 5 lines
Quoted 5 lines

BTW, tools/vm/ was reported yesterday and a fix is already in tip/perf/core/:

https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/tools/vm?id=f6489bc2d402c0db84aa64f13b864d17f7eecb07

Quoted 8 lines
Quoted 2 lines
Age       Commit message (Expand)                                           Author                   Files Lines
12 hours  tools vm: Fix build due to removal of tools/lib/api/fs/debugfs.h  Arnaldo Carvalho de Melo	1  -3/+3

It's not that this wasn't fixed quickly (kudos for that, btw), rather it's that the breakage should have been avoided altogether.

But if this is an isolated incident, then fair enough, I'll stop whining.

Expressing concern is not a problem, its an opportunity for us to try and get them addressed and improve so that others don't get afraid of the processes in place.

- Arnaldo

author reviewer
#69 lore raw

PATCH 15/15 perf tools: Switch to tracing_path interface on appropriate places

In reply to Jiri Olsa

Using tracing_path interface on several places, that more or less copy the functionality of tracing_path interface.

---
 tools/perf/tests/openat-syscall-all-cpus.c |  9 +++------
 tools/perf/tests/openat-syscall.c          | 11 ++++-------
 tools/perf/tests/parse-events.c            | 16 ++--------------
 tools/perf/util/probe-file.c               | 14 ++------------
 4 files changed, 11 insertions(+), 39 deletions(-)
tools/perf/tests/openat-syscall-all-cpus.c +3 -6
index a38adf94c731..495d8126b722 100644
@@ -15,6 +15,7 @@ int test__openat_syscall_event_on_all_cpus(void)
 	cpu_set_t cpu_set;
 	struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
 	char sbuf[STRERR_BUFSIZE];
+	char errbuf[BUFSIZ];
 
 	if (threads == NULL) {
 		pr_debug("thread_map__new\n");
@@ -31,12 +32,8 @@ int test__openat_syscall_event_on_all_cpus(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
 	if (evsel == NULL) {
-		if (tracefs__configured())
-			pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
-		else if (debugfs__configured())
-			pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
-		else
-			pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
+		tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
+		pr_err("%s\n", errbuf);
 		goto out_thread_map_delete;
 	}
 
tools/perf/tests/openat-syscall.c +4 -7
index 8048c7d7cd67..08ac9d94a050 100644
@@ -1,4 +1,4 @@
-#include <api/fs/fs.h>
+#include <api/fs/tracing_path.h>
 #include "thread_map.h"
 #include "evsel.h"
 #include "debug.h"
@@ -11,6 +11,7 @@ int test__openat_syscall_event(void)
 	unsigned int nr_openat_calls = 111, i;
 	struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
 	char sbuf[STRERR_BUFSIZE];
+	char errbuf[BUFSIZ];
 
 	if (threads == NULL) {
 		pr_debug("thread_map__new\n");
@@ -19,12 +20,8 @@ int test__openat_syscall_event(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
 	if (evsel == NULL) {
-		if (tracefs__configured())
-			pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
-		else if (debugfs__configured())
-			pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
-		else
-			pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
+		tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
+		pr_err("%s\n", errbuf);
 		goto out_thread_map_delete;
 	}
 
tools/perf/tests/parse-events.c +2 -14
index 91fbfd593c4a..3a2ebe666192 100644
@@ -1261,23 +1261,11 @@ test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist)
 
 static int count_tracepoints(void)
 {
-	char events_path[PATH_MAX];
 	struct dirent *events_ent;
-	const char *mountpoint;
 	DIR *events_dir;
 	int cnt = 0;
 
-	mountpoint = tracefs__mountpoint();
-	if (mountpoint) {
-		scnprintf(events_path, PATH_MAX, "%s/events",
-			  mountpoint);
-	} else {
-		mountpoint = debugfs__mountpoint();
-		scnprintf(events_path, PATH_MAX, "%s/tracing/events",
-			  mountpoint);
-	}
-
-	events_dir = opendir(events_path);
+	events_dir = opendir(tracing_events_path);
 
 	TEST_ASSERT_VAL("Can't open events dir", events_dir);
 
@@ -1294,7 +1282,7 @@ static int count_tracepoints(void)
 			continue;
 
 		scnprintf(sys_path, PATH_MAX, "%s/%s",
-			  events_path, events_ent->d_name);
+			  tracing_events_path, events_ent->d_name);
 
 		sys_dir = opendir(sys_path);
 		TEST_ASSERT_VAL("Can't open sys dir", sys_dir);
tools/perf/util/probe-file.c +2 -12
index de0df1e6222a..cbc5783389f8 100644
@@ -22,7 +22,7 @@
 #include "color.h"
 #include "symbol.h"
 #include "thread.h"
-#include <api/fs/fs.h>
+#include <api/fs/tracing_path.h>
 #include "probe-event.h"
 #include "probe-file.h"
 #include "session.h"
@@ -72,21 +72,11 @@ static void print_both_open_warning(int kerr, int uerr)
 static int open_probe_events(const char *trace_file, bool readwrite)
 {
 	char buf[PATH_MAX];
-	const char *__debugfs;
 	const char *tracing_dir = "";
 	int ret;
 
-	__debugfs = tracefs__mountpoint();
-	if (__debugfs == NULL) {
-		tracing_dir = "tracing/";
-
-		__debugfs = debugfs__mountpoint();
-		if (__debugfs == NULL)
-			return -ENOTSUP;
-	}
-
 	ret = e_snprintf(buf, PATH_MAX, "%s/%s%s",
-			 __debugfs, tracing_dir, trace_file);
+			 tracing_path, tracing_dir, trace_file);
 	if (ret >= 0) {
 		pr_debug("Opening %s write=%d\n", buf, readwrite);
 		if (readwrite && !probe_event_dry_run)
Signature · 1 line
2.4.3
#70 lore raw

[tip:perf/core] perf tools: Switch to tracing_path interface on appropriate places

perf tools: Switch to tracing_path interface on appropriate places
Commit-ID:  fbf99625b88fd8808bf2b80efac453d63cae08e8
Gitweb:     http://git.kernel.org/tip/fbf99625b88fd8808bf2b80efac453d63cae08e8
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 2 Sep 2015 09:56:45 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 14 Sep 2015 12:50:16 -0300

perf tools: Switch to tracing_path interface on appropriate places

Using tracing_path interface on several places, that more or less copy the functionality of tracing_path interface.

---
 tools/perf/tests/openat-syscall-all-cpus.c |  9 +++------
 tools/perf/tests/openat-syscall.c          | 11 ++++-------
 tools/perf/tests/parse-events.c            | 16 ++--------------
 tools/perf/util/probe-file.c               | 14 ++------------
 4 files changed, 11 insertions(+), 39 deletions(-)
tools/perf/tests/openat-syscall-all-cpus.c +3 -6
index a38adf9..495d812 100644
@@ -15,6 +15,7 @@ int test__openat_syscall_event_on_all_cpus(void)
 	cpu_set_t cpu_set;
 	struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
 	char sbuf[STRERR_BUFSIZE];
+	char errbuf[BUFSIZ];
 
 	if (threads == NULL) {
 		pr_debug("thread_map__new\n");
@@ -31,12 +32,8 @@ int test__openat_syscall_event_on_all_cpus(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
 	if (evsel == NULL) {
-		if (tracefs__configured())
-			pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
-		else if (debugfs__configured())
-			pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
-		else
-			pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
+		tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
+		pr_err("%s\n", errbuf);
 		goto out_thread_map_delete;
 	}
 
tools/perf/tests/openat-syscall.c +4 -7
index 8048c7d..08ac9d9 100644
@@ -1,4 +1,4 @@
-#include <api/fs/fs.h>
+#include <api/fs/tracing_path.h>
 #include "thread_map.h"
 #include "evsel.h"
 #include "debug.h"
@@ -11,6 +11,7 @@ int test__openat_syscall_event(void)
 	unsigned int nr_openat_calls = 111, i;
 	struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
 	char sbuf[STRERR_BUFSIZE];
+	char errbuf[BUFSIZ];
 
 	if (threads == NULL) {
 		pr_debug("thread_map__new\n");
@@ -19,12 +20,8 @@ int test__openat_syscall_event(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
 	if (evsel == NULL) {
-		if (tracefs__configured())
-			pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
-		else if (debugfs__configured())
-			pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
-		else
-			pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
+		tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
+		pr_err("%s\n", errbuf);
 		goto out_thread_map_delete;
 	}
 
tools/perf/tests/parse-events.c +2 -14
index 91fbfd5..3a2ebe6 100644
@@ -1261,23 +1261,11 @@ test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist)
 
 static int count_tracepoints(void)
 {
-	char events_path[PATH_MAX];
 	struct dirent *events_ent;
-	const char *mountpoint;
 	DIR *events_dir;
 	int cnt = 0;
 
-	mountpoint = tracefs__mountpoint();
-	if (mountpoint) {
-		scnprintf(events_path, PATH_MAX, "%s/events",
-			  mountpoint);
-	} else {
-		mountpoint = debugfs__mountpoint();
-		scnprintf(events_path, PATH_MAX, "%s/tracing/events",
-			  mountpoint);
-	}
-
-	events_dir = opendir(events_path);
+	events_dir = opendir(tracing_events_path);
 
 	TEST_ASSERT_VAL("Can't open events dir", events_dir);
 
@@ -1294,7 +1282,7 @@ static int count_tracepoints(void)
 			continue;
 
 		scnprintf(sys_path, PATH_MAX, "%s/%s",
-			  events_path, events_ent->d_name);
+			  tracing_events_path, events_ent->d_name);
 
 		sys_dir = opendir(sys_path);
 		TEST_ASSERT_VAL("Can't open sys dir", sys_dir);
tools/perf/util/probe-file.c +2 -12
index 499c83c..89dbeb9 100644
@@ -22,7 +22,7 @@
 #include "color.h"
 #include "symbol.h"
 #include "thread.h"
-#include <api/fs/fs.h>
+#include <api/fs/tracing_path.h>
 #include "probe-event.h"
 #include "probe-file.h"
 #include "session.h"
@@ -72,21 +72,11 @@ static void print_both_open_warning(int kerr, int uerr)
 static int open_probe_events(const char *trace_file, bool readwrite)
 {
 	char buf[PATH_MAX];
-	const char *__debugfs;
 	const char *tracing_dir = "";
 	int ret;
 
-	__debugfs = tracefs__mountpoint();
-	if (__debugfs == NULL) {
-		tracing_dir = "tracing/";
-
-		__debugfs = debugfs__mountpoint();
-		if (__debugfs == NULL)
-			return -ENOTSUP;
-	}
-
 	ret = e_snprintf(buf, PATH_MAX, "%s/%s%s",
-			 __debugfs, tracing_dir, trace_file);
+			 tracing_path, tracing_dir, trace_file);
 	if (ret >= 0) {
 		pr_debug("Opening %s write=%d\n", buf, readwrite);
 		if (readwrite && !probe_event_dry_run)
#71 lore raw
In reply to Jiri Olsa
Quoted 10 lines · Jiri Olsa

hi,
this patchset moves all filesystem we use under api/fs/fs.c framework and adds new tracing_path object to get tracing area (path).

It unifies the way we use debugfs/tracefs paths and removes some redundant code.

It's base for the tracepoint parsing error reporting I posted recently.

also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/tracing_path

jirka