All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/15] perf tools: Cleanup filesystem api
@ 2015-09-02  7:56 Jiri Olsa
  2015-09-02  7:56 ` [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller Jiri Olsa
                   ` (15 more replies)
  0 siblings, 16 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-02 13:00   ` Arnaldo Carvalho de Melo
  2015-09-05 14:00   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 02/15] perf tools: Remove mountpoint arg from perf_debugfs_mount Jiri Olsa
                   ` (14 subsequent siblings)
  15 siblings, 2 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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.

Link: http://lkml.kernel.org/n/tip-fda5a524tfapmpb85bmaigo2@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/parse-events.y | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 591905a02b92..9cd70819c795 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -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;
 }
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 02/15] perf tools: Remove mountpoint arg from perf_debugfs_mount
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
  2015-09-02  7:56 ` [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-08 14:32   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 03/15] perf tools: Move tracing_path stuff under same namespace Jiri Olsa
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

Link: http://lkml.kernel.org/n/tip-7bbr92o7gwv5bkpancqoypz3@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/perf.c      |  2 +-
 tools/perf/util/util.c | 14 +++++++-------
 tools/perf/util/util.h |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 07dbff5c0e60..f500a4b40722 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -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:
 	 *
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 7acafb3c5592..74f71f8afcc2 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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;
 }
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 291be1d84bc3..184d40048faa 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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);
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 03/15] perf tools: Move tracing_path stuff under same namespace
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
  2015-09-02  7:56 ` [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller Jiri Olsa
  2015-09-02  7:56 ` [PATCH 02/15] perf tools: Remove mountpoint arg from perf_debugfs_mount Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-08 14:33   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c Jiri Olsa
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

Link: http://lkml.kernel.org/n/tip-miy6kftxxryjf40b3qb6eknc@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/perf.c      | 10 ++++++----
 tools/perf/util/util.c | 20 ++++++++++----------
 tools/perf/util/util.h |  4 ++--
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index f500a4b40722..0e99cd1de9dd 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -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:
 	 *
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 74f71f8afcc2..b959f783f6cd 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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)
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 184d40048faa..230c4124bfa7 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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);
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (2 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 03/15] perf tools: Move tracing_path stuff under same namespace Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-04 11:35   ` Matt Fleming
  2015-09-08 14:33   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object Jiri Olsa
                   ` (11 subsequent siblings)
  15 siblings, 2 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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.

Link: http://lkml.kernel.org/n/tip-xqvrud2e3z4uynvnu3imlu2y@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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

diff --git a/tools/lib/api/fs/Build b/tools/lib/api/fs/Build
index 6de5a4f0b501..fa726f679b29 100644
--- a/tools/lib/api/fs/Build
+++ b/tools/lib/api/fs/Build
@@ -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
diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
new file mode 100644
index 000000000000..1fd6e1f99234
--- /dev/null
+++ b/tools/lib/api/fs/tracing_path.c
@@ -0,0 +1,83 @@
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "debugfs.h"
+#include "tracefs.h"
+
+#include "tracing_path.h"
+
+
+char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
+char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
+
+
+static void __tracing_path_set(const char *tracing, const char *mountpoint)
+{
+	snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
+		 mountpoint, tracing);
+	snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
+		 mountpoint, tracing, "events");
+}
+
+static const char *tracing_path_tracefs_mount(void)
+{
+	const char *mnt;
+
+	mnt = tracefs_mount(NULL);
+	if (!mnt)
+		return NULL;
+
+	__tracing_path_set("", mnt);
+
+	return mnt;
+}
+
+static const char *tracing_path_debugfs_mount(void)
+{
+	const char *mnt;
+
+	mnt = debugfs_mount(NULL);
+	if (!mnt)
+		return NULL;
+
+	__tracing_path_set("tracing/", mnt);
+
+	return mnt;
+}
+
+const char *tracing_path_mount(void)
+{
+	const char *mnt;
+
+	mnt = tracing_path_tracefs_mount();
+	if (mnt)
+		return mnt;
+
+	mnt = tracing_path_debugfs_mount();
+
+	return mnt;
+}
+
+void tracing_path_set(const char *mntpt)
+{
+	__tracing_path_set("tracing/", mntpt);
+}
+
+char *get_tracing_file(const char *name)
+{
+	char *file;
+
+	if (asprintf(&file, "%s/%s", tracing_path, name) < 0)
+		return NULL;
+
+	return file;
+}
+
+void put_tracing_file(char *file)
+{
+	free(file);
+}
diff --git a/tools/lib/api/fs/tracing_path.h b/tools/lib/api/fs/tracing_path.h
new file mode 100644
index 000000000000..b132dc599fe5
--- /dev/null
+++ b/tools/lib/api/fs/tracing_path.h
@@ -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 */
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 0e99cd1de9dd..f2fc019b3671 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -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[] =
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index d826e6f515db..3840176642f8 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -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"
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 22245986e59e..d995743cb673 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -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"
 
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
index b90e646c7a91..2f4996ab313d 100644
--- a/tools/perf/util/trace-event.c
+++ b/tools/perf/util/trace-event.c
@@ -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"
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index b959f783f6cd..49a5c6ad55f5 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -34,9 +34,6 @@ bool test_attr__enabled;
 bool perf_host  = true;
 bool perf_guest = false;
 
-char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
-char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
-
 void event_attr_init(struct perf_event_attr *attr)
 {
 	if (!perf_host)
@@ -390,73 +387,6 @@ void set_term_quiet_input(struct termios *old)
 	tcsetattr(0, TCSANOW, &tc);
 }
 
-static void __tracing_path_set(const char *tracing, const char *mountpoint)
-{
-	snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
-		 mountpoint, tracing);
-	snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
-		 mountpoint, tracing, "events");
-}
-
-static const char *tracing_path_tracefs_mount(void)
-{
-	const char *mnt;
-
-	mnt = tracefs_mount(NULL);
-	if (!mnt)
-		return NULL;
-
-	__tracing_path_set("", mnt);
-
-	return mnt;
-}
-
-static const char *tracing_path_debugfs_mount(void)
-{
-	const char *mnt;
-
-	mnt = debugfs_mount(NULL);
-	if (!mnt)
-		return NULL;
-
-	__tracing_path_set("tracing/", mnt);
-
-	return mnt;
-}
-
-const char *tracing_path_mount(void)
-{
-	const char *mnt;
-
-	mnt = tracing_path_tracefs_mount();
-	if (mnt)
-		return mnt;
-
-	mnt = tracing_path_debugfs_mount();
-
-	return mnt;
-}
-
-void tracing_path_set(const char *mntpt)
-{
-	__tracing_path_set("tracing/", mntpt);
-}
-
-char *get_tracing_file(const char *name)
-{
-	char *file;
-
-	if (asprintf(&file, "%s/%s", tracing_path, name) < 0)
-		return NULL;
-
-	return file;
-}
-
-void put_tracing_file(char *file)
-{
-	free(file);
-}
-
 int parse_nsec_time(const char *str, u64 *ptime)
 {
 	u64 time_sec, time_nsec;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 230c4124bfa7..f9a9717d2aff 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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).
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (3 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-02 13:12   ` Arnaldo Carvalho de Melo
                     ` (3 more replies)
  2015-09-02  7:56 ` [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic Jiri Olsa
                   ` (10 subsequent siblings)
  15 siblings, 4 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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.

Link: http://lkml.kernel.org/n/tip-bq0f0l4r0bjvy0pjp4m759kv@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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(-)

diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index eb7cf4d18f8a..c707cfb32782 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -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);
-}
diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 1fd6e1f99234..3b3e4f5fc50b 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -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);
+}
diff --git a/tools/lib/api/fs/tracing_path.h b/tools/lib/api/fs/tracing_path.h
index b132dc599fe5..3f233ac70b6f 100644
--- a/tools/lib/api/fs/tracing_path.h
+++ b/tools/lib/api/fs/tracing_path.h
@@ -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 */
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4e3abba03062..215653274102 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -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:
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (4 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-02 13:18   ` Arnaldo Carvalho de Melo
  2015-09-15  6:59   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 07/15] tools lib api: Add STR and PATH_MAX macros to fs object Jiri Olsa
                   ` (9 subsequent siblings)
  15 siblings, 2 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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.

Link: http://lkml.kernel.org/n/tip-5y7nboe2xe619hp649ry58z6@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/api/fs/tracing_path.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 3b3e4f5fc50b..b0ee3b3acef0 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -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);
 }
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 07/15] tools lib api: Add STR and PATH_MAX macros to fs object
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (5 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-08 14:34   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 08/15] tools lib api: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c Jiri Olsa
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

Link: http://lkml.kernel.org/n/tip-mrjj0llsem9pjakkrx9o0j6g@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/api/fs/fs.c | 3 +++
 tools/lib/api/fs/fs.h | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 128ef6332a6b..5e838d3c419d 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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,
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 6caa2bbc6cec..fd6288d73383 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 08/15] tools lib api: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (6 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 07/15] tools lib api: Add STR and PATH_MAX macros to fs object Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-08 14:34   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 09/15] tools lib api: Add debugfs into fs.c object Jiri Olsa
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

Link: http://lkml.kernel.org/n/tip-b2cd1bb7yvbazq5oua24oz18@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/api/fs/fs.c | 8 ++++++++
 tools/lib/api/fs/fs.h | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5e838d3c419d..0700eb953495 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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,
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index fd6288d73383..674efc8dfd9b 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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);
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 09/15] tools lib api: Add debugfs into fs.c object
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (7 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 08/15] tools lib api: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-08 14:34   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 10/15] tools lib api: Add tracefs " Jiri Olsa
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

Link: http://lkml.kernel.org/n/tip-6n8d5bxn47oqcvlhzqw09dol@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/api/fs/fs.c | 31 +++++++++++++++++++++++++------
 tools/lib/api/fs/fs.h |  1 +
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 0700eb953495..798052cbc7c0 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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)
 {
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 674efc8dfd9b..a4e6b1d93d2f 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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);
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 10/15] tools lib api: Add tracefs into fs.c object
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (8 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 09/15] tools lib api: Add debugfs into fs.c object Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-08 14:35   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 11/15] tools lib api: Add mount support for fs Jiri Olsa
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

Link: http://lkml.kernel.org/n/tip-m27bbnbg8s03mt2na6zghf9q@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/api/fs/fs.c | 28 ++++++++++++++++++++++++++++
 tools/lib/api/fs/fs.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 798052cbc7c0..ef16d2a83a27 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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)
 {
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index a4e6b1d93d2f..9013227ae0d1 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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);
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 11/15] tools lib api: Add mount support for fs
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (9 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 10/15] tools lib api: Add tracefs " Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-04 14:14   ` Raphaël Beamonte
  2015-09-08 14:35   ` [tip:perf/core] tools lib api fs: Add FSTYPE__mount() method tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 12/15] tools lib api: Add configured support for fs Jiri Olsa
                   ` (4 subsequent siblings)
  15 siblings, 2 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

Link: http://lkml.kernel.org/n/tip-ja49vwfiq2qqkmoxx9yk26lm@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/api/fs/fs.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 tools/lib/api/fs/fs.h | 15 +++++++++++----
 2 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index ef16d2a83a27..bc93baf33fff 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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)
 {
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 9013227ae0d1..a9627ea5e6ae 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 12/15] tools lib api: Add configured support for fs
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (10 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 11/15] tools lib api: Add mount support for fs Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-02 13:39   ` Arnaldo Carvalho de Melo
  2015-09-08 14:35   ` [tip:perf/core] tools lib api fs: Add FSTYPE__configured() method tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 13/15] tools lib api: Replace debugfs/tracefs objects interface with fs.c Jiri Olsa
                   ` (3 subsequent siblings)
  15 siblings, 2 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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.

Link: http://lkml.kernel.org/n/tip-csvlq2hr43ys3u7nfs2up9y9@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/api/fs/fs.c | 23 ++++++++++++++---------
 tools/lib/api/fs/fs.h |  5 ++++-
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index bc93baf33fff..8afe08a99bc6 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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);
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index a9627ea5e6ae..f654bcb99d1e 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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)
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 13/15] tools lib api: Replace debugfs/tracefs objects interface with fs.c
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (11 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 12/15] tools lib api: Add configured support for fs Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-15  6:59   ` [tip:perf/core] tools lib api fs: Replace debugfs/ tracefs " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 14/15] tools lib api: Remove debugfs, tracefs and findfs objects Jiri Olsa
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

Switching to the fs.c related filesystem framework.

Link: http://lkml.kernel.org/n/tip-csvlq2hr43ys3u7nfs2up9y9@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 8afe08a99bc6..791509346178 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include <sys/mount.h>
 
-#include "debugfs.h"
 #include "fs.h"
 
 #define _STR(x) #x
diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index b0ee3b3acef0..b53aa9c8d1c8 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -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,
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index fc1cffb1b7a2..dd94b4ca2213 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -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"
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index b81cec33b4b2..310aba2756a8 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -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"
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
index a572f87e9c8d..a38adf94c731 100644
--- a/tools/perf/tests/openat-syscall-all-cpus.c
+++ b/tools/perf/tests/openat-syscall-all-cpus.c
@@ -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");
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
index c9a37bc6b33a..8048c7d7cd67 100644
--- a/tools/perf/tests/openat-syscall.c
+++ b/tools/perf/tests/openat-syscall.c
@@ -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");
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 9b6b2b6324a1..91fbfd593c4a 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -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);
 	}
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index c53f79123b37..771ade4d5966 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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>
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index eb5f18b75402..1104c584e3d9 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -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;
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index bbb243717ec8..de0df1e6222a 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -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;
 	}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index f9a9717d2aff..91b3bb79a4b5 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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>
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 14/15] tools lib api: Remove debugfs, tracefs and findfs objects
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (12 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 13/15] tools lib api: Replace debugfs/tracefs objects interface with fs.c Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-15  6:59   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  2015-09-02  7:56 ` [PATCH 15/15] perf tools: Switch to tracing_path interface on appropriate places Jiri Olsa
  2015-09-02  8:01 ` [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
  15 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

Link: http://lkml.kernel.org/n/tip-4ylqs27bec3m6ofefqo0eek4@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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

diff --git a/tools/lib/api/fs/Build b/tools/lib/api/fs/Build
index fa726f679b29..f4ed9629ae85 100644
--- a/tools/lib/api/fs/Build
+++ b/tools/lib/api/fs/Build
@@ -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
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
deleted file mode 100644
index c707cfb32782..000000000000
--- a/tools/lib/api/fs/debugfs.c
+++ /dev/null
@@ -1,77 +0,0 @@
-#define _GNU_SOURCE
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <sys/vfs.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <linux/kernel.h>
-
-#include "debugfs.h"
-#include "tracefs.h"
-
-#ifndef DEBUGFS_DEFAULT_PATH
-#define DEBUGFS_DEFAULT_PATH		"/sys/kernel/debug"
-#endif
-
-char debugfs_mountpoint[PATH_MAX + 1] = DEBUGFS_DEFAULT_PATH;
-
-static const char * const debugfs_known_mountpoints[] = {
-	DEBUGFS_DEFAULT_PATH,
-	"/debug",
-	0,
-};
-
-static bool debugfs_found;
-
-bool debugfs_configured(void)
-{
-	return debugfs_find_mountpoint() != NULL;
-}
-
-/* find the path to the mounted debugfs */
-const char *debugfs_find_mountpoint(void)
-{
-	const char *ret;
-
-	if (debugfs_found)
-		return (const char *)debugfs_mountpoint;
-
-	ret = find_mountpoint("debugfs", (long) DEBUGFS_MAGIC,
-			      debugfs_mountpoint, PATH_MAX + 1,
-			      debugfs_known_mountpoints);
-	if (ret)
-		debugfs_found = true;
-
-	return ret;
-}
-
-/* mount the debugfs somewhere if it's not mounted */
-char *debugfs_mount(const char *mountpoint)
-{
-	/* see if it's already mounted */
-	if (debugfs_find_mountpoint())
-		goto out;
-
-	/* if not mounted and no argument */
-	if (mountpoint == NULL) {
-		/* see if environment variable set */
-		mountpoint = getenv(PERF_DEBUGFS_ENVIRONMENT);
-		/* if no environment variable, use default */
-		if (mountpoint == NULL)
-			mountpoint = DEBUGFS_DEFAULT_PATH;
-	}
-
-	if (mount(NULL, mountpoint, "debugfs", 0, NULL) < 0)
-		return NULL;
-
-	/* save the mountpoint */
-	debugfs_found = true;
-	strncpy(debugfs_mountpoint, mountpoint, sizeof(debugfs_mountpoint));
-out:
-	return debugfs_mountpoint;
-}
diff --git a/tools/lib/api/fs/debugfs.h b/tools/lib/api/fs/debugfs.h
deleted file mode 100644
index 455023698d2b..000000000000
--- a/tools/lib/api/fs/debugfs.h
+++ /dev/null
@@ -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__ */
diff --git a/tools/lib/api/fs/findfs.c b/tools/lib/api/fs/findfs.c
deleted file mode 100644
index 49946cb6d7af..000000000000
--- a/tools/lib/api/fs/findfs.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <sys/vfs.h>
-
-#include "findfs.h"
-
-/* verify that a mountpoint is actually the type we want */
-
-int valid_mountpoint(const char *mount, long magic)
-{
-	struct statfs st_fs;
-
-	if (statfs(mount, &st_fs) < 0)
-		return -ENOENT;
-	else if ((long)st_fs.f_type != magic)
-		return -ENOENT;
-
-	return 0;
-}
-
-/* find the path to a mounted file system */
-const char *find_mountpoint(const char *fstype, long magic,
-			    char *mountpoint, int len,
-			    const char * const *known_mountpoints)
-{
-	const char * const *ptr;
-	char format[128];
-	char type[100];
-	FILE *fp;
-
-	if (known_mountpoints) {
-		ptr = known_mountpoints;
-		while (*ptr) {
-			if (valid_mountpoint(*ptr, magic) == 0) {
-				strncpy(mountpoint, *ptr, len - 1);
-				mountpoint[len-1] = 0;
-				return mountpoint;
-			}
-			ptr++;
-		}
-	}
-
-	/* give up and parse /proc/mounts */
-	fp = fopen("/proc/mounts", "r");
-	if (fp == NULL)
-		return NULL;
-
-	snprintf(format, 128, "%%*s %%%ds %%99s %%*s %%*d %%*d\n", len);
-
-	while (fscanf(fp, format, mountpoint, type) == 2) {
-		if (strcmp(type, fstype) == 0)
-			break;
-	}
-	fclose(fp);
-
-	if (strcmp(type, fstype) != 0)
-		return NULL;
-
-	return mountpoint;
-}
diff --git a/tools/lib/api/fs/findfs.h b/tools/lib/api/fs/findfs.h
deleted file mode 100644
index b6f5d05acc42..000000000000
--- a/tools/lib/api/fs/findfs.h
+++ /dev/null
@@ -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__ */
diff --git a/tools/lib/api/fs/tracefs.c b/tools/lib/api/fs/tracefs.c
deleted file mode 100644
index e4aa9688b71e..000000000000
--- a/tools/lib/api/fs/tracefs.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <sys/vfs.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <linux/kernel.h>
-
-#include "tracefs.h"
-
-#ifndef TRACEFS_DEFAULT_PATH
-#define TRACEFS_DEFAULT_PATH		"/sys/kernel/tracing"
-#endif
-
-char tracefs_mountpoint[PATH_MAX + 1] = TRACEFS_DEFAULT_PATH;
-
-static const char * const tracefs_known_mountpoints[] = {
-	TRACEFS_DEFAULT_PATH,
-	"/sys/kernel/debug/tracing",
-	"/tracing",
-	"/trace",
-	0,
-};
-
-static bool tracefs_found;
-
-bool tracefs_configured(void)
-{
-	return tracefs_find_mountpoint() != NULL;
-}
-
-/* find the path to the mounted tracefs */
-const char *tracefs_find_mountpoint(void)
-{
-	const char *ret;
-
-	if (tracefs_found)
-		return (const char *)tracefs_mountpoint;
-
-	ret = find_mountpoint("tracefs", (long) TRACEFS_MAGIC,
-			      tracefs_mountpoint, PATH_MAX + 1,
-			      tracefs_known_mountpoints);
-
-	if (ret)
-		tracefs_found = true;
-
-	return ret;
-}
-
-/* mount the tracefs somewhere if it's not mounted */
-char *tracefs_mount(const char *mountpoint)
-{
-	/* see if it's already mounted */
-	if (tracefs_find_mountpoint())
-		goto out;
-
-	/* if not mounted and no argument */
-	if (mountpoint == NULL) {
-		/* see if environment variable set */
-		mountpoint = getenv(PERF_TRACEFS_ENVIRONMENT);
-		/* if no environment variable, use default */
-		if (mountpoint == NULL)
-			mountpoint = TRACEFS_DEFAULT_PATH;
-	}
-
-	if (mount(NULL, mountpoint, "tracefs", 0, NULL) < 0)
-		return NULL;
-
-	/* save the mountpoint */
-	tracefs_found = true;
-	strncpy(tracefs_mountpoint, mountpoint, sizeof(tracefs_mountpoint));
-out:
-	return tracefs_mountpoint;
-}
diff --git a/tools/lib/api/fs/tracefs.h b/tools/lib/api/fs/tracefs.h
deleted file mode 100644
index da780ac49acb..000000000000
--- a/tools/lib/api/fs/tracefs.h
+++ /dev/null
@@ -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__ */
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 15/15] perf tools: Switch to tracing_path interface on appropriate places
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (13 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 14/15] tools lib api: Remove debugfs, tracefs and findfs objects Jiri Olsa
@ 2015-09-02  7:56 ` Jiri Olsa
  2015-09-15  7:00   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2015-09-02  8:01 ` [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
  15 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  7:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

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

Link: http://lkml.kernel.org/n/tip-nvxvjo2bpsjf3hhz3ylulw1k@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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(-)

diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
index a38adf94c731..495d8126b722 100644
--- a/tools/perf/tests/openat-syscall-all-cpus.c
+++ b/tools/perf/tests/openat-syscall-all-cpus.c
@@ -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;
 	}
 
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
index 8048c7d7cd67..08ac9d94a050 100644
--- a/tools/perf/tests/openat-syscall.c
+++ b/tools/perf/tests/openat-syscall.c
@@ -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;
 	}
 
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 91fbfd593c4a..3a2ebe666192 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -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);
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index de0df1e6222a..cbc5783389f8 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -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)
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* Re: [PATCH 00/15] perf tools: Cleanup filesystem api
  2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
                   ` (14 preceding siblings ...)
  2015-09-02  7:56 ` [PATCH 15/15] perf tools: Switch to tracing_path interface on appropriate places Jiri Olsa
@ 2015-09-02  8:01 ` Jiri Olsa
  15 siblings, 0 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02  8:01 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, David Ahern, Ingo Molnar,
	Namhyung Kim, Peter Zijlstra, Matt Fleming,
	Raphaël Beamonte, Steven Rostedt

On Wed, Sep 02, 2015 at 09:56:30AM +0200, Jiri Olsa wrote:
> 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller
  2015-09-02  7:56 ` [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller Jiri Olsa
@ 2015-09-02 13:00   ` Arnaldo Carvalho de Melo
  2015-09-02 13:34     ` Jiri Olsa
  2015-09-05 14:00   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  1 sibling, 1 reply; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-02 13:00 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

Em Wed, Sep 02, 2015 at 09:56:31AM +0200, Jiri Olsa escreveu:
> 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
 
> Link: http://lkml.kernel.org/n/tip-fda5a524tfapmpb85bmaigo2@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/util/parse-events.y | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> index 591905a02b92..9cd70819c795 100644
> --- a/tools/perf/util/parse-events.y
> +++ b/tools/perf/util/parse-events.y
> @@ -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;
>  }
> -- 
> 2.4.3

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object
  2015-09-02  7:56 ` [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object Jiri Olsa
@ 2015-09-02 13:12   ` Arnaldo Carvalho de Melo
  2015-09-04 11:36   ` Matt Fleming
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-02 13:12 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

Em Wed, Sep 02, 2015 at 09:56:35AM +0200, Jiri Olsa escreveu:
> 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

 
> Link: http://lkml.kernel.org/n/tip-bq0f0l4r0bjvy0pjp4m759kv@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  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(-)
> 
> diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
> index eb7cf4d18f8a..c707cfb32782 100644
> --- a/tools/lib/api/fs/debugfs.c
> +++ b/tools/lib/api/fs/debugfs.c
> @@ -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);
> -}
> diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
> index 1fd6e1f99234..3b3e4f5fc50b 100644
> --- a/tools/lib/api/fs/tracing_path.c
> +++ b/tools/lib/api/fs/tracing_path.c
> @@ -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);
> +}
> diff --git a/tools/lib/api/fs/tracing_path.h b/tools/lib/api/fs/tracing_path.h
> index b132dc599fe5..3f233ac70b6f 100644
> --- a/tools/lib/api/fs/tracing_path.h
> +++ b/tools/lib/api/fs/tracing_path.h
> @@ -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 */
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 4e3abba03062..215653274102 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -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:
> -- 
> 2.4.3

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic
  2015-09-02  7:56 ` [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic Jiri Olsa
@ 2015-09-02 13:18   ` Arnaldo Carvalho de Melo
  2015-09-02 13:44     ` Jiri Olsa
  2015-09-15  6:59   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  1 sibling, 1 reply; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-02 13:18 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

Em Wed, Sep 02, 2015 at 09:56:36AM +0200, Jiri Olsa escreveu:
> 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

> both debugfs/tracefs words in error message plus the tracing_path
> instead of debugfs_mountpoint.
> 
> Link: http://lkml.kernel.org/n/tip-5y7nboe2xe619hp649ry58z6@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/lib/api/fs/tracing_path.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
> index 3b3e4f5fc50b..b0ee3b3acef0 100644
> --- a/tools/lib/api/fs/tracing_path.c
> +++ b/tools/lib/api/fs/tracing_path.c
> @@ -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

>  			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);
>  }
> -- 
> 2.4.3

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller
  2015-09-02 13:00   ` Arnaldo Carvalho de Melo
@ 2015-09-02 13:34     ` Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02 13:34 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Matt Fleming, Raphaël Beamonte,
	Steven Rostedt

On Wed, Sep 02, 2015 at 10:00:53AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Sep 02, 2015 at 09:56:31AM +0200, Jiri Olsa escreveu:
> > 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

> 
> Applying to perf/urgent,

thanks,
jirka

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/15] tools lib api: Add configured support for fs
  2015-09-02  7:56 ` [PATCH 12/15] tools lib api: Add configured support for fs Jiri Olsa
@ 2015-09-02 13:39   ` Arnaldo Carvalho de Melo
  2015-09-02 13:41     ` Arnaldo Carvalho de Melo
  2015-09-02 13:46     ` Jiri Olsa
  2015-09-08 14:35   ` [tip:perf/core] tools lib api fs: Add FSTYPE__configured() method tip-bot for Jiri Olsa
  1 sibling, 2 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-02 13:39 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:
> 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
 
> 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
 
> Link: http://lkml.kernel.org/n/tip-csvlq2hr43ys3u7nfs2up9y9@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/lib/api/fs/fs.c | 23 ++++++++++++++---------
>  tools/lib/api/fs/fs.h |  5 ++++-
>  2 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
> index bc93baf33fff..8afe08a99bc6 100644
> --- a/tools/lib/api/fs/fs.c
> +++ b/tools/lib/api/fs/fs.c
> @@ -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);
> diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
> index a9627ea5e6ae..f654bcb99d1e 100644
> --- a/tools/lib/api/fs/fs.h
> +++ b/tools/lib/api/fs/fs.h
> @@ -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)
> -- 
> 2.4.3

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/15] tools lib api: Add configured support for fs
  2015-09-02 13:39   ` Arnaldo Carvalho de Melo
@ 2015-09-02 13:41     ` Arnaldo Carvalho de Melo
  2015-09-02 13:46     ` Jiri Olsa
  1 sibling, 0 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-02 13:41 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming, Raphaël Beamonte, Steven Rostedt

Em Wed, Sep 02, 2015 at 10:39:31AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:
> > 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
>  
> > 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

> 
> - Arnaldo
>  
> > Link: http://lkml.kernel.org/n/tip-csvlq2hr43ys3u7nfs2up9y9@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/lib/api/fs/fs.c | 23 ++++++++++++++---------
> >  tools/lib/api/fs/fs.h |  5 ++++-
> >  2 files changed, 18 insertions(+), 10 deletions(-)
> > 
> > diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
> > index bc93baf33fff..8afe08a99bc6 100644
> > --- a/tools/lib/api/fs/fs.c
> > +++ b/tools/lib/api/fs/fs.c
> > @@ -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);
> > diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
> > index a9627ea5e6ae..f654bcb99d1e 100644
> > --- a/tools/lib/api/fs/fs.h
> > +++ b/tools/lib/api/fs/fs.h
> > @@ -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)
> > -- 
> > 2.4.3

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic
  2015-09-02 13:18   ` Arnaldo Carvalho de Melo
@ 2015-09-02 13:44     ` Jiri Olsa
  2015-09-02 14:16       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02 13:44 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Matt Fleming, Raphaël Beamonte,
	Steven Rostedt

On Wed, Sep 02, 2015 at 10:18:44AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Sep 02, 2015 at 09:56:36AM +0200, Jiri Olsa escreveu:
> > 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
> 
> > both debugfs/tracefs words in error message plus the tracing_path
> > instead of debugfs_mountpoint.
> > 
> > Link: http://lkml.kernel.org/n/tip-5y7nboe2xe619hp649ry58z6@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/lib/api/fs/tracing_path.c | 20 ++++++++++----------
> >  1 file changed, 10 insertions(+), 10 deletions(-)
> > 
> > diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
> > index 3b3e4f5fc50b..b0ee3b3acef0 100644
> > --- a/tools/lib/api/fs/tracing_path.c
> > +++ b/tools/lib/api/fs/tracing_path.c
> > @@ -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

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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/15] tools lib api: Add configured support for fs
  2015-09-02 13:39   ` Arnaldo Carvalho de Melo
  2015-09-02 13:41     ` Arnaldo Carvalho de Melo
@ 2015-09-02 13:46     ` Jiri Olsa
  2015-09-02 14:17       ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-02 13:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Matt Fleming, Raphaël Beamonte,
	Steven Rostedt

On Wed, Sep 02, 2015 at 10:39:31AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:
> > 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

> 
> 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
>  
> > 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic
  2015-09-02 13:44     ` Jiri Olsa
@ 2015-09-02 14:16       ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-02 14:16 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Matt Fleming, Raphaël Beamonte,
	Steven Rostedt

Em Wed, Sep 02, 2015 at 03:44:50PM +0200, Jiri Olsa escreveu:
> On Wed, Sep 02, 2015 at 10:18:44AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Sep 02, 2015 at 09:56:36AM +0200, Jiri Olsa escreveu:
> > > 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
> > 
> > > both debugfs/tracefs words in error message plus the tracing_path
> > > instead of debugfs_mountpoint.
> > > 
> > > Link: http://lkml.kernel.org/n/tip-5y7nboe2xe619hp649ry58z6@git.kernel.org
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > ---
> > >  tools/lib/api/fs/tracing_path.c | 20 ++++++++++----------
> > >  1 file changed, 10 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
> > > index 3b3e4f5fc50b..b0ee3b3acef0 100644
> > > --- a/tools/lib/api/fs/tracing_path.c
> > > +++ b/tools/lib/api/fs/tracing_path.c
> > > @@ -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
> 
> 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/15] tools lib api: Add configured support for fs
  2015-09-02 13:46     ` Jiri Olsa
@ 2015-09-02 14:17       ` Arnaldo Carvalho de Melo
  2015-09-02 16:52         ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-02 14:17 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Matt Fleming, Raphaël Beamonte,
	Steven Rostedt

Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:
> On Wed, Sep 02, 2015 at 10:39:31AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:
> > > Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)

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

> > > 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.
 
> > 
> > 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 :)
> >  
> > > 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/15] tools lib api: Add configured support for fs
  2015-09-02 14:17       ` Arnaldo Carvalho de Melo
@ 2015-09-02 16:52         ` Arnaldo Carvalho de Melo
  2015-09-04  7:08           ` Jiri Olsa
  0 siblings, 1 reply; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-02 16:52 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Matt Fleming, Raphaël Beamonte,
	Steven Rostedt

Em Wed, Sep 02, 2015 at 11:17:59AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:
> > On Wed, Sep 02, 2015 at 10:39:31AM -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:
> > > > Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)
> 
> The cut'n'paste error I mentioned was in the above line, BTW.
> 
> > > > 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.

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

- Arnaldo
  
> > > 
> > > 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 :)
> > >  
> > > > 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/15] tools lib api: Add configured support for fs
  2015-09-02 16:52         ` Arnaldo Carvalho de Melo
@ 2015-09-04  7:08           ` Jiri Olsa
  2015-09-04 16:42             ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-04  7:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Matt Fleming, Raphaël Beamonte,
	Steven Rostedt

On Wed, Sep 02, 2015 at 01:52:28PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Sep 02, 2015 at 11:17:59AM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:
> > > On Wed, Sep 02, 2015 at 10:39:31AM -0300, Arnaldo Carvalho de Melo wrote:
> > > > Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:
> > > > > Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)
> > 
> > The cut'n'paste error I mentioned was in the above line, BTW.
> > 
> > > > > 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.
> 
> 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c
  2015-09-02  7:56 ` [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c Jiri Olsa
@ 2015-09-04 11:35   ` Matt Fleming
  2015-09-04 13:28     ` Raphaël Beamonte
  2015-09-08 14:33   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  1 sibling, 1 reply; 72+ messages in thread
From: Matt Fleming @ 2015-09-04 11:35 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, David Ahern, Ingo Molnar,
	Namhyung Kim, Peter Zijlstra, Raphaël Beamonte,
	Steven Rostedt

On Wed, 02 Sep, at 09:56:34AM, Jiri Olsa wrote:
> 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.
> 
> Link: http://lkml.kernel.org/n/tip-xqvrud2e3z4uynvnu3imlu2y@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  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

Reviewed-by: Matt Fleming <matt.fleming@intel.com>

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object
  2015-09-02  7:56 ` [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object Jiri Olsa
  2015-09-02 13:12   ` Arnaldo Carvalho de Melo
@ 2015-09-04 11:36   ` Matt Fleming
  2015-09-04 13:41   ` Raphaël Beamonte
  2015-09-08 14:33   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  3 siblings, 0 replies; 72+ messages in thread
From: Matt Fleming @ 2015-09-04 11:36 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, David Ahern, Ingo Molnar,
	Namhyung Kim, Peter Zijlstra, Raphaël Beamonte,
	Steven Rostedt

On Wed, 02 Sep, at 09:56:35AM, Jiri Olsa wrote:
> 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.
> 
> Link: http://lkml.kernel.org/n/tip-bq0f0l4r0bjvy0pjp4m759kv@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  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(-)

Reviewed-by: Matt Fleming <matt.fleming@intel.com>

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c
  2015-09-04 11:35   ` Matt Fleming
@ 2015-09-04 13:28     ` Raphaël Beamonte
  0 siblings, 0 replies; 72+ messages in thread
From: Raphaël Beamonte @ 2015-09-04 13:28 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, David Ahern,
	Ingo Molnar, Namhyung Kim, Peter Zijlstra, Steven Rostedt

2015-09-04 7:35 GMT-04:00 Matt Fleming <matt@codeblueprint.co.uk>:
> On Wed, 02 Sep, at 09:56:34AM, Jiri Olsa wrote:
>> 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.
>>
>> Link: http://lkml.kernel.org/n/tip-xqvrud2e3z4uynvnu3imlu2y@git.kernel.org
>> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>> ---
>>  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
>
> Reviewed-by: Matt Fleming <matt.fleming@intel.com>
>
> --
> Matt Fleming, Intel Open Source Technology Center

I can get behind that too.
Reviewed-by: Raphaël Beamonte <raphael.beamonte@gmail.com>

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object
  2015-09-02  7:56 ` [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object Jiri Olsa
  2015-09-02 13:12   ` Arnaldo Carvalho de Melo
  2015-09-04 11:36   ` Matt Fleming
@ 2015-09-04 13:41   ` Raphaël Beamonte
  2015-09-04 13:48     ` Jiri Olsa
  2015-09-08 14:33   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
  3 siblings, 1 reply; 72+ messages in thread
From: Raphaël Beamonte @ 2015-09-04 13:41 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, David Ahern, Ingo Molnar,
	Namhyung Kim, Peter Zijlstra, Matt Fleming, Steven Rostedt

2015-09-02 9:12 GMT-04:00 Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>:
> 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?

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object
  2015-09-04 13:41   ` Raphaël Beamonte
@ 2015-09-04 13:48     ` Jiri Olsa
  2015-09-04 13:51       ` Raphaël Beamonte
  0 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-04 13:48 UTC (permalink / raw)
  To: Raphaël Beamonte
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, David Ahern,
	Ingo Molnar, Namhyung Kim, Peter Zijlstra, Matt Fleming,
	Steven Rostedt

On Fri, Sep 04, 2015 at 09:41:59AM -0400, Raphaël Beamonte wrote:
> 2015-09-02 9:12 GMT-04:00 Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>:
> > 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object
  2015-09-04 13:48     ` Jiri Olsa
@ 2015-09-04 13:51       ` Raphaël Beamonte
  0 siblings, 0 replies; 72+ messages in thread
From: Raphaël Beamonte @ 2015-09-04 13:51 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, David Ahern,
	Ingo Molnar, Namhyung Kim, Peter Zijlstra, Matt Fleming,
	Steven Rostedt

2015-09-04 9:48 GMT-04:00 Jiri Olsa <jolsa@redhat.com>:
> 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 <jolsa@kernel.org>:
> 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.
>
> Link: http://lkml.kernel.org/n/tip-bq0f0l4r0bjvy0pjp4m759kv@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  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(-)

Reviewed-by: Raphaël Beamonte <raphael.beamonte@gmail.com>

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 11/15] tools lib api: Add mount support for fs
  2015-09-02  7:56 ` [PATCH 11/15] tools lib api: Add mount support for fs Jiri Olsa
@ 2015-09-04 14:14   ` Raphaël Beamonte
  2015-09-04 14:20     ` Steven Rostedt
  2015-09-04 14:26     ` Jiri Olsa
  2015-09-08 14:35   ` [tip:perf/core] tools lib api fs: Add FSTYPE__mount() method tip-bot for Jiri Olsa
  1 sibling, 2 replies; 72+ messages in thread
From: Raphaël Beamonte @ 2015-09-04 14:14 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, David Ahern, Ingo Molnar,
	Namhyung Kim, Peter Zijlstra, Matt Fleming, Steven Rostedt

2015-09-02 3:56 GMT-04:00 Jiri Olsa <jolsa@kernel.org>:
> Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)
> interface that tries to mount the filesystem in case no mount is found.
>
> Link: http://lkml.kernel.org/n/tip-ja49vwfiq2qqkmoxx9yk26lm@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  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.


> diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
> index ef16d2a83a27..bc93baf33fff 100644
> --- a/tools/lib/api/fs/fs.c
> +++ b/tools/lib/api/fs/fs.c
> @@ -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)
>  {
> diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
> index 9013227ae0d1..a9627ea5e6ae 100644
> --- a/tools/lib/api/fs/fs.h
> +++ b/tools/lib/api/fs/fs.h
> @@ -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
>

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 11/15] tools lib api: Add mount support for fs
  2015-09-04 14:14   ` Raphaël Beamonte
@ 2015-09-04 14:20     ` Steven Rostedt
  2015-09-04 14:26     ` Jiri Olsa
  1 sibling, 0 replies; 72+ messages in thread
From: Steven Rostedt @ 2015-09-04 14:20 UTC (permalink / raw)
  To: Raphaël Beamonte
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, David Ahern,
	Ingo Molnar, Namhyung Kim, Peter Zijlstra, Matt Fleming

On Fri, 4 Sep 2015 10:14:28 -0400
Raphaël Beamonte <raphael.beamonte@gmail.com> wrote:

> 2015-09-02 3:56 GMT-04:00 Jiri Olsa <jolsa@kernel.org>:
> > Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)
> > interface that tries to mount the filesystem in case no mount is found.
> >
> > Link: http://lkml.kernel.org/n/tip-ja49vwfiq2qqkmoxx9yk26lm@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  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.
> 

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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 11/15] tools lib api: Add mount support for fs
  2015-09-04 14:14   ` Raphaël Beamonte
  2015-09-04 14:20     ` Steven Rostedt
@ 2015-09-04 14:26     ` Jiri Olsa
  2015-09-04 14:57       ` Steven Rostedt
  1 sibling, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-04 14:26 UTC (permalink / raw)
  To: Raphaël Beamonte
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, David Ahern,
	Ingo Molnar, Namhyung Kim, Peter Zijlstra, Matt Fleming,
	Steven Rostedt

On Fri, Sep 04, 2015 at 10:14:28AM -0400, Raphaël Beamonte wrote:
> 2015-09-02 3:56 GMT-04:00 Jiri Olsa <jolsa@kernel.org>:
> > Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)
> > interface that tries to mount the filesystem in case no mount is found.
> >
> > Link: http://lkml.kernel.org/n/tip-ja49vwfiq2qqkmoxx9yk26lm@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  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.

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

> 
> 
> > diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
> > index ef16d2a83a27..bc93baf33fff 100644
> > --- a/tools/lib/api/fs/fs.c
> > +++ b/tools/lib/api/fs/fs.c
> > @@ -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)
> >  {
> > diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
> > index 9013227ae0d1..a9627ea5e6ae 100644
> > --- a/tools/lib/api/fs/fs.h
> > +++ b/tools/lib/api/fs/fs.h
> > @@ -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
> >

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 11/15] tools lib api: Add mount support for fs
  2015-09-04 14:26     ` Jiri Olsa
@ 2015-09-04 14:57       ` Steven Rostedt
  2015-09-04 15:00         ` Steven Rostedt
  0 siblings, 1 reply; 72+ messages in thread
From: Steven Rostedt @ 2015-09-04 14:57 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Raphaël Beamonte, Jiri Olsa, Arnaldo Carvalho de Melo, lkml,
	David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming

On Fri, 4 Sep 2015 16:26:31 +0200
Jiri Olsa <jolsa@redhat.com> wrote:

> On Fri, Sep 04, 2015 at 10:14:28AM -0400, Raphaël Beamonte wrote:
> > 2015-09-02 3:56 GMT-04:00 Jiri Olsa <jolsa@kernel.org>:
> > > Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)
> > > interface that tries to mount the filesystem in case no mount is found.
> > >
> > > Link: http://lkml.kernel.org/n/tip-ja49vwfiq2qqkmoxx9yk26lm@git.kernel.org
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > ---
> > >  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.
> 
> 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.


> 
> 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 11/15] tools lib api: Add mount support for fs
  2015-09-04 14:57       ` Steven Rostedt
@ 2015-09-04 15:00         ` Steven Rostedt
  2015-09-04 15:12           ` Raphaël Beamonte
  0 siblings, 1 reply; 72+ messages in thread
From: Steven Rostedt @ 2015-09-04 15:00 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Raphaël Beamonte, Jiri Olsa, Arnaldo Carvalho de Melo, lkml,
	David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming

On Fri, 4 Sep 2015 10:57:00 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:


> > 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


^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 11/15] tools lib api: Add mount support for fs
  2015-09-04 15:00         ` Steven Rostedt
@ 2015-09-04 15:12           ` Raphaël Beamonte
  0 siblings, 0 replies; 72+ messages in thread
From: Raphaël Beamonte @ 2015-09-04 15:12 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Jiri Olsa, Jiri Olsa, Arnaldo Carvalho de Melo, lkml,
	David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Matt Fleming

2015-09-04 11:00 GMT-04:00 Steven Rostedt <rostedt@goodmis.org>:
> 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 <jolsa@kernel.org>:
> Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)
> interface that tries to mount the filesystem in case no mount is found.
>
> Link: http://lkml.kernel.org/n/tip-ja49vwfiq2qqkmoxx9yk26lm@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  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)
Reviewed-by: Raphaël Beamonte <raphael.beamonte@gmail.com>

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/15] tools lib api: Add configured support for fs
  2015-09-04  7:08           ` Jiri Olsa
@ 2015-09-04 16:42             ` Arnaldo Carvalho de Melo
  2015-09-04 17:45               ` Jiri Olsa
  0 siblings, 1 reply; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-04 16:42 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Matt Fleming, Raphaël Beamonte,
	Steven Rostedt

Em Fri, Sep 04, 2015 at 09:08:45AM +0200, Jiri Olsa escreveu:
> On Wed, Sep 02, 2015 at 01:52:28PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Sep 02, 2015 at 11:17:59AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:
> > > > On Wed, Sep 02, 2015 at 10:39:31AM -0300, Arnaldo Carvalho de Melo wrote:
> > > > > Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:
> > > > > > Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)
> > > 
> > > The cut'n'paste error I mentioned was in the above line, BTW.
> > > 
> > > > > > 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.
> > 
> > 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

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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/15] tools lib api: Add configured support for fs
  2015-09-04 16:42             ` Arnaldo Carvalho de Melo
@ 2015-09-04 17:45               ` Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-04 17:45 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Matt Fleming, Raphaël Beamonte,
	Steven Rostedt

On Fri, Sep 04, 2015 at 01:42:51PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Sep 04, 2015 at 09:08:45AM +0200, Jiri Olsa escreveu:
> > On Wed, Sep 02, 2015 at 01:52:28PM -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Wed, Sep 02, 2015 at 11:17:59AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > > Em Wed, Sep 02, 2015 at 03:46:25PM +0200, Jiri Olsa escreveu:
> > > > > On Wed, Sep 02, 2015 at 10:39:31AM -0300, Arnaldo Carvalho de Melo wrote:
> > > > > > Em Wed, Sep 02, 2015 at 09:56:42AM +0200, Jiri Olsa escreveu:
> > > > > > > Adding name__mount (where name is in sysfs,procfs,debugfs,tracefs)
> > > > 
> > > > The cut'n'paste error I mentioned was in the above line, BTW.
> > > > 
> > > > > > > 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.
> > > 
> > > 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
> 
> 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [tip:perf/urgent] perf tools: Fix parse_events_add_pmu caller
  2015-09-02  7:56 ` [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller Jiri Olsa
  2015-09-02 13:00   ` Arnaldo Carvalho de Melo
@ 2015-09-05 14:00   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-05 14:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: raphael.beamonte, linux-kernel, a.p.zijlstra, dsahern, hpa,
	rostedt, namhyung, tglx, acme, matt, jolsa, mingo

Commit-ID:  5ad4da4302712fba10624d28cb6c269fee592b69
Gitweb:     http://git.kernel.org/tip/5ad4da4302712fba10624d28cb6c269fee592b69
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:31 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Fixes: 36adec85a86f ("perf tools: Change parse_events_add_pmu interface")
Link: http://lkml.kernel.org/r/1441180605-24737-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.y | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 591905a..9cd7081 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -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;
 }

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] perf tools: Remove mountpoint arg from perf_debugfs_mount
  2015-09-02  7:56 ` [PATCH 02/15] perf tools: Remove mountpoint arg from perf_debugfs_mount Jiri Olsa
@ 2015-09-08 14:32   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: raphael.beamonte, tglx, a.p.zijlstra, mingo, linux-kernel, matt,
	jolsa, hpa, dsahern, rostedt, namhyung, acme

Commit-ID:  f6a09af7de3b39b1e4fcff7374871f834498b7f0
Gitweb:     http://git.kernel.org/tip/f6a09af7de3b39b1e4fcff7374871f834498b7f0
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:32 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/perf.c      |  2 +-
 tools/perf/util/util.c | 14 +++++++-------
 tools/perf/util/util.h |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 07dbff5..f500a4b 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -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:
 	 *
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 7acafb3..74f71f8 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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;
 }
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 09c1a8b..48ec232 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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);
 

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] perf tools: Move tracing_path stuff under same namespace
  2015-09-02  7:56 ` [PATCH 03/15] perf tools: Move tracing_path stuff under same namespace Jiri Olsa
@ 2015-09-08 14:33   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dsahern, a.p.zijlstra, raphael.beamonte, rostedt, tglx, hpa,
	mingo, acme, linux-kernel, jolsa, matt, namhyung

Commit-ID:  65d4b265103a3cb2f0993c946815157a38797421
Gitweb:     http://git.kernel.org/tip/65d4b265103a3cb2f0993c946815157a38797421
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:33 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/perf.c      | 10 ++++++----
 tools/perf/util/util.c | 20 ++++++++++----------
 tools/perf/util/util.h |  4 ++--
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index f500a4b..0e99cd1 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -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:
 	 *
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 74f71f8..b959f78 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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)
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 48ec232..bbf8a93 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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);
 

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Move tracing_path interface into api/fs/tracing_path.c
  2015-09-02  7:56 ` [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c Jiri Olsa
  2015-09-04 11:35   ` Matt Fleming
@ 2015-09-08 14:33   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dsahern, a.p.zijlstra, linux-kernel, mingo, tglx, acme, hpa,
	namhyung, raphael.beamonte, matt.fleming, rostedt, jolsa

Commit-ID:  592d5a6ba86a31681fa5e20a63a145b0a3b53c8a
Gitweb:     http://git.kernel.org/tip/592d5a6ba86a31681fa5e20a63a145b0a3b53c8a
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:34 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reviewed-by: Matt Fleming <matt.fleming@intel.com>
Reviewed-by: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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(-)

diff --git a/tools/lib/api/fs/Build b/tools/lib/api/fs/Build
index 6de5a4f..fa726f6 100644
--- a/tools/lib/api/fs/Build
+++ b/tools/lib/api/fs/Build
@@ -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
diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
new file mode 100644
index 0000000..1fd6e1f
--- /dev/null
+++ b/tools/lib/api/fs/tracing_path.c
@@ -0,0 +1,83 @@
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "debugfs.h"
+#include "tracefs.h"
+
+#include "tracing_path.h"
+
+
+char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
+char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
+
+
+static void __tracing_path_set(const char *tracing, const char *mountpoint)
+{
+	snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
+		 mountpoint, tracing);
+	snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
+		 mountpoint, tracing, "events");
+}
+
+static const char *tracing_path_tracefs_mount(void)
+{
+	const char *mnt;
+
+	mnt = tracefs_mount(NULL);
+	if (!mnt)
+		return NULL;
+
+	__tracing_path_set("", mnt);
+
+	return mnt;
+}
+
+static const char *tracing_path_debugfs_mount(void)
+{
+	const char *mnt;
+
+	mnt = debugfs_mount(NULL);
+	if (!mnt)
+		return NULL;
+
+	__tracing_path_set("tracing/", mnt);
+
+	return mnt;
+}
+
+const char *tracing_path_mount(void)
+{
+	const char *mnt;
+
+	mnt = tracing_path_tracefs_mount();
+	if (mnt)
+		return mnt;
+
+	mnt = tracing_path_debugfs_mount();
+
+	return mnt;
+}
+
+void tracing_path_set(const char *mntpt)
+{
+	__tracing_path_set("tracing/", mntpt);
+}
+
+char *get_tracing_file(const char *name)
+{
+	char *file;
+
+	if (asprintf(&file, "%s/%s", tracing_path, name) < 0)
+		return NULL;
+
+	return file;
+}
+
+void put_tracing_file(char *file)
+{
+	free(file);
+}
diff --git a/tools/lib/api/fs/tracing_path.h b/tools/lib/api/fs/tracing_path.h
new file mode 100644
index 0000000..b132dc5
--- /dev/null
+++ b/tools/lib/api/fs/tracing_path.h
@@ -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 */
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 0e99cd1..f2fc019 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -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[] =
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index d826e6f..3840176 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -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"
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 2224598..d995743 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -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"
 
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
index b90e646..2f4996a 100644
--- a/tools/perf/util/trace-event.c
+++ b/tools/perf/util/trace-event.c
@@ -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"
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index b959f78..49a5c6a 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -34,9 +34,6 @@ bool test_attr__enabled;
 bool perf_host  = true;
 bool perf_guest = false;
 
-char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
-char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
-
 void event_attr_init(struct perf_event_attr *attr)
 {
 	if (!perf_host)
@@ -390,73 +387,6 @@ void set_term_quiet_input(struct termios *old)
 	tcsetattr(0, TCSANOW, &tc);
 }
 
-static void __tracing_path_set(const char *tracing, const char *mountpoint)
-{
-	snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
-		 mountpoint, tracing);
-	snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
-		 mountpoint, tracing, "events");
-}
-
-static const char *tracing_path_tracefs_mount(void)
-{
-	const char *mnt;
-
-	mnt = tracefs_mount(NULL);
-	if (!mnt)
-		return NULL;
-
-	__tracing_path_set("", mnt);
-
-	return mnt;
-}
-
-static const char *tracing_path_debugfs_mount(void)
-{
-	const char *mnt;
-
-	mnt = debugfs_mount(NULL);
-	if (!mnt)
-		return NULL;
-
-	__tracing_path_set("tracing/", mnt);
-
-	return mnt;
-}
-
-const char *tracing_path_mount(void)
-{
-	const char *mnt;
-
-	mnt = tracing_path_tracefs_mount();
-	if (mnt)
-		return mnt;
-
-	mnt = tracing_path_debugfs_mount();
-
-	return mnt;
-}
-
-void tracing_path_set(const char *mntpt)
-{
-	__tracing_path_set("tracing/", mntpt);
-}
-
-char *get_tracing_file(const char *name)
-{
-	char *file;
-
-	if (asprintf(&file, "%s/%s", tracing_path, name) < 0)
-		return NULL;
-
-	return file;
-}
-
-void put_tracing_file(char *file)
-{
-	free(file);
-}
-
 int parse_nsec_time(const char *str, u64 *ptime)
 {
 	u64 time_sec, time_nsec;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index bbf8a93..495b99c 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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).

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Move debugfs__strerror_open into tracing_path.c object
  2015-09-02  7:56 ` [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object Jiri Olsa
                     ` (2 preceding siblings ...)
  2015-09-04 13:41   ` Raphaël Beamonte
@ 2015-09-08 14:33   ` tip-bot for Jiri Olsa
  3 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, jolsa, tglx, mingo, linux-kernel, matt.fleming,
	raphael.beamonte, acme, hpa, rostedt, dsahern, namhyung

Commit-ID:  988bdb319246dea977a375beee39a5452e99b3ef
Gitweb:     http://git.kernel.org/tip/988bdb319246dea977a375beee39a5452e99b3ef
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:35 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reviewed-by: Matt Fleming <matt.fleming@intel.com>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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(-)

diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index eb7cf4d..c707cfb 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -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);
-}
diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 1fd6e1f..3b3e4f5 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -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);
+}
diff --git a/tools/lib/api/fs/tracing_path.h b/tools/lib/api/fs/tracing_path.h
index b132dc5..3f233ac 100644
--- a/tools/lib/api/fs/tracing_path.h
+++ b/tools/lib/api/fs/tracing_path.h
@@ -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 */
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4e3abba..2156532 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -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:

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Add STR and PATH_MAX macros to fs object
  2015-09-02  7:56 ` [PATCH 07/15] tools lib api: Add STR and PATH_MAX macros to fs object Jiri Olsa
@ 2015-09-08 14:34   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, raphael.beamonte, linux-kernel, hpa, mingo, matt, dsahern,
	acme, a.p.zijlstra, rostedt, tglx, namhyung

Commit-ID:  b86b0d3570273c6ddc16b1972e82bf7778346286
Gitweb:     http://git.kernel.org/tip/b86b0d3570273c6ddc16b1972e82bf7778346286
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:37 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-8-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/fs.c | 3 +++
 tools/lib/api/fs/fs.h | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 128ef63..5e838d3 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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,
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 6caa2bb..fd6288d 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c
  2015-09-02  7:56 ` [PATCH 08/15] tools lib api: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c Jiri Olsa
@ 2015-09-08 14:34   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, matt, raphael.beamonte, jolsa, mingo, hpa,
	linux-kernel, tglx, dsahern, rostedt, namhyung, acme

Commit-ID:  41e3a1fece31d0b2383281e4a917ff4b16fa9223
Gitweb:     http://git.kernel.org/tip/41e3a1fece31d0b2383281e4a917ff4b16fa9223
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:38 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Link: http://lkml.kernel.org/n/tip-b2cd1bb7yvbazq5oua24oz18@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-9-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/fs.c | 8 ++++++++
 tools/lib/api/fs/fs.h | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5e838d3..0700eb9 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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,
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index fd6288d..674efc8 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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);
 

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Add debugfs into fs.c object
  2015-09-02  7:56 ` [PATCH 09/15] tools lib api: Add debugfs into fs.c object Jiri Olsa
@ 2015-09-08 14:34   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, tglx, raphael.beamonte, acme, mingo, hpa, jolsa,
	namhyung, matt, a.p.zijlstra, rostedt, dsahern

Commit-ID:  8ccfabdb873df2e18b235bfaf2722f7528d220f1
Gitweb:     http://git.kernel.org/tip/8ccfabdb873df2e18b235bfaf2722f7528d220f1
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:39 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-10-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/fs.c | 31 +++++++++++++++++++++++++------
 tools/lib/api/fs/fs.h |  1 +
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 0700eb9..798052c 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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)
 {
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 674efc8..a4e6b1d 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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);

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Add tracefs into fs.c object
  2015-09-02  7:56 ` [PATCH 10/15] tools lib api: Add tracefs " Jiri Olsa
@ 2015-09-08 14:35   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, namhyung, tglx, a.p.zijlstra, hpa, dsahern, mingo,
	matt, rostedt, acme, jolsa, raphael.beamonte

Commit-ID:  c495afb4988dcbb8bae11b8f1bbb7e11f172672b
Gitweb:     http://git.kernel.org/tip/c495afb4988dcbb8bae11b8f1bbb7e11f172672b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:40 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-11-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/fs.c | 28 ++++++++++++++++++++++++++++
 tools/lib/api/fs/fs.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 798052c..ef16d2a 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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)
 {
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index a4e6b1d..9013227 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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);

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Add FSTYPE__mount() method
  2015-09-02  7:56 ` [PATCH 11/15] tools lib api: Add mount support for fs Jiri Olsa
  2015-09-04 14:14   ` Raphaël Beamonte
@ 2015-09-08 14:35   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: matt, raphael.beamonte, dsahern, rostedt, jolsa, tglx,
	a.p.zijlstra, linux-kernel, acme, namhyung, mingo, hpa

Commit-ID:  73ca85ad364769ffa312b1d892816d8fa23a02bf
Gitweb:     http://git.kernel.org/tip/73ca85ad364769ffa312b1d892816d8fa23a02bf
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:41 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-12-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/fs.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 tools/lib/api/fs/fs.h | 15 +++++++++++----
 2 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index ef16d2a..bc93baf 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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)
 {
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 9013227..a9627ea 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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);

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Add FSTYPE__configured() method
  2015-09-02  7:56 ` [PATCH 12/15] tools lib api: Add configured support for fs Jiri Olsa
  2015-09-02 13:39   ` Arnaldo Carvalho de Melo
@ 2015-09-08 14:35   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-08 14:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: matt, linux-kernel, mingo, acme, hpa, namhyung, dsahern, rostedt,
	raphael.beamonte, jolsa, tglx, a.p.zijlstra

Commit-ID:  709adcb33928b5bf965587b23ed6544e964584a3
Gitweb:     http://git.kernel.org/tip/709adcb33928b5bf965587b23ed6544e964584a3
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:42 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-13-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/fs.c | 23 ++++++++++++++---------
 tools/lib/api/fs/fs.h |  5 ++++-
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index bc93baf..8afe08a 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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);
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index a9627ea..f654bcb 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -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)

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Make tracing_path_strerror_open message generic
  2015-09-02  7:56 ` [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic Jiri Olsa
  2015-09-02 13:18   ` Arnaldo Carvalho de Melo
@ 2015-09-15  6:59   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-15  6:59 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, a.p.zijlstra, dsahern, tglx, acme, jolsa,
	raphael.beamonte, matt, rostedt, linux-kernel, hpa, mingo

Commit-ID:  4f234f06d608635a1cff936131285a91af213b37
Gitweb:     http://git.kernel.org/tip/4f234f06d608635a1cff936131285a91af213b37
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:36 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-7-git-send-email-jolsa@kernel.org
[ Add comment for the ENOENT case out of this patch discussion thread ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/api/fs/tracing_path.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 3b3e4f5..1e0bb0d 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -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);
 }

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Replace debugfs/ tracefs objects interface with fs.c
  2015-09-02  7:56 ` [PATCH 13/15] tools lib api: Replace debugfs/tracefs objects interface with fs.c Jiri Olsa
@ 2015-09-15  6:59   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-15  6:59 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, matt, a.p.zijlstra, linux-kernel, dsahern, namhyung, tglx,
	rostedt, acme, mingo, hpa, raphael.beamonte

Commit-ID:  4605eab3487dc818b1f3cbee2cd139cca3564be7
Gitweb:     http://git.kernel.org/tip/4605eab3487dc818b1f3cbee2cd139cca3564be7
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:43 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-14-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 8afe08a..7915093 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include <sys/mount.h>
 
-#include "debugfs.h"
 #include "fs.h"
 
 #define _STR(x) #x
diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 1e0bb0d..38aca2d 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -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,
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index fc1cffb..dd94b4c 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -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"
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index ee2c46d..2bec9c1 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -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"
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
index a572f87..a38adf9 100644
--- a/tools/perf/tests/openat-syscall-all-cpus.c
+++ b/tools/perf/tests/openat-syscall-all-cpus.c
@@ -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");
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
index c9a37bc..8048c7d 100644
--- a/tools/perf/tests/openat-syscall.c
+++ b/tools/perf/tests/openat-syscall.c
@@ -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");
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 9b6b2b63..91fbfd5 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -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);
 	}
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index c53f791..771ade4 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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>
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 3da9e1c..5964ecc 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -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;
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 38c0a62..499c83c 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -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;
 	}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 495b99c..3d5b01e 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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>

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-02  7:56 ` [PATCH 14/15] tools lib api: Remove debugfs, tracefs and findfs objects Jiri Olsa
@ 2015-09-15  6:59   ` tip-bot for Jiri Olsa
  2015-09-22  0:20     ` Vinson Lee
  0 siblings, 1 reply; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-15  6:59 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: matt, jolsa, rostedt, linux-kernel, hpa, raphael.beamonte,
	a.p.zijlstra, acme, namhyung, mingo, tglx, dsahern

Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-15-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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(-)

diff --git a/tools/lib/api/fs/Build b/tools/lib/api/fs/Build
index fa726f6..f4ed962 100644
--- a/tools/lib/api/fs/Build
+++ b/tools/lib/api/fs/Build
@@ -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
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
deleted file mode 100644
index c707cfb..0000000
--- a/tools/lib/api/fs/debugfs.c
+++ /dev/null
@@ -1,77 +0,0 @@
-#define _GNU_SOURCE
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <sys/vfs.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <linux/kernel.h>
-
-#include "debugfs.h"
-#include "tracefs.h"
-
-#ifndef DEBUGFS_DEFAULT_PATH
-#define DEBUGFS_DEFAULT_PATH		"/sys/kernel/debug"
-#endif
-
-char debugfs_mountpoint[PATH_MAX + 1] = DEBUGFS_DEFAULT_PATH;
-
-static const char * const debugfs_known_mountpoints[] = {
-	DEBUGFS_DEFAULT_PATH,
-	"/debug",
-	0,
-};
-
-static bool debugfs_found;
-
-bool debugfs_configured(void)
-{
-	return debugfs_find_mountpoint() != NULL;
-}
-
-/* find the path to the mounted debugfs */
-const char *debugfs_find_mountpoint(void)
-{
-	const char *ret;
-
-	if (debugfs_found)
-		return (const char *)debugfs_mountpoint;
-
-	ret = find_mountpoint("debugfs", (long) DEBUGFS_MAGIC,
-			      debugfs_mountpoint, PATH_MAX + 1,
-			      debugfs_known_mountpoints);
-	if (ret)
-		debugfs_found = true;
-
-	return ret;
-}
-
-/* mount the debugfs somewhere if it's not mounted */
-char *debugfs_mount(const char *mountpoint)
-{
-	/* see if it's already mounted */
-	if (debugfs_find_mountpoint())
-		goto out;
-
-	/* if not mounted and no argument */
-	if (mountpoint == NULL) {
-		/* see if environment variable set */
-		mountpoint = getenv(PERF_DEBUGFS_ENVIRONMENT);
-		/* if no environment variable, use default */
-		if (mountpoint == NULL)
-			mountpoint = DEBUGFS_DEFAULT_PATH;
-	}
-
-	if (mount(NULL, mountpoint, "debugfs", 0, NULL) < 0)
-		return NULL;
-
-	/* save the mountpoint */
-	debugfs_found = true;
-	strncpy(debugfs_mountpoint, mountpoint, sizeof(debugfs_mountpoint));
-out:
-	return debugfs_mountpoint;
-}
diff --git a/tools/lib/api/fs/debugfs.h b/tools/lib/api/fs/debugfs.h
deleted file mode 100644
index 4550236..0000000
--- a/tools/lib/api/fs/debugfs.h
+++ /dev/null
@@ -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__ */
diff --git a/tools/lib/api/fs/findfs.c b/tools/lib/api/fs/findfs.c
deleted file mode 100644
index 49946cb..0000000
--- a/tools/lib/api/fs/findfs.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <sys/vfs.h>
-
-#include "findfs.h"
-
-/* verify that a mountpoint is actually the type we want */
-
-int valid_mountpoint(const char *mount, long magic)
-{
-	struct statfs st_fs;
-
-	if (statfs(mount, &st_fs) < 0)
-		return -ENOENT;
-	else if ((long)st_fs.f_type != magic)
-		return -ENOENT;
-
-	return 0;
-}
-
-/* find the path to a mounted file system */
-const char *find_mountpoint(const char *fstype, long magic,
-			    char *mountpoint, int len,
-			    const char * const *known_mountpoints)
-{
-	const char * const *ptr;
-	char format[128];
-	char type[100];
-	FILE *fp;
-
-	if (known_mountpoints) {
-		ptr = known_mountpoints;
-		while (*ptr) {
-			if (valid_mountpoint(*ptr, magic) == 0) {
-				strncpy(mountpoint, *ptr, len - 1);
-				mountpoint[len-1] = 0;
-				return mountpoint;
-			}
-			ptr++;
-		}
-	}
-
-	/* give up and parse /proc/mounts */
-	fp = fopen("/proc/mounts", "r");
-	if (fp == NULL)
-		return NULL;
-
-	snprintf(format, 128, "%%*s %%%ds %%99s %%*s %%*d %%*d\n", len);
-
-	while (fscanf(fp, format, mountpoint, type) == 2) {
-		if (strcmp(type, fstype) == 0)
-			break;
-	}
-	fclose(fp);
-
-	if (strcmp(type, fstype) != 0)
-		return NULL;
-
-	return mountpoint;
-}
diff --git a/tools/lib/api/fs/findfs.h b/tools/lib/api/fs/findfs.h
deleted file mode 100644
index b6f5d05..0000000
--- a/tools/lib/api/fs/findfs.h
+++ /dev/null
@@ -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__ */
diff --git a/tools/lib/api/fs/tracefs.c b/tools/lib/api/fs/tracefs.c
deleted file mode 100644
index e4aa968..0000000
--- a/tools/lib/api/fs/tracefs.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <sys/vfs.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <linux/kernel.h>
-
-#include "tracefs.h"
-
-#ifndef TRACEFS_DEFAULT_PATH
-#define TRACEFS_DEFAULT_PATH		"/sys/kernel/tracing"
-#endif
-
-char tracefs_mountpoint[PATH_MAX + 1] = TRACEFS_DEFAULT_PATH;
-
-static const char * const tracefs_known_mountpoints[] = {
-	TRACEFS_DEFAULT_PATH,
-	"/sys/kernel/debug/tracing",
-	"/tracing",
-	"/trace",
-	0,
-};
-
-static bool tracefs_found;
-
-bool tracefs_configured(void)
-{
-	return tracefs_find_mountpoint() != NULL;
-}
-
-/* find the path to the mounted tracefs */
-const char *tracefs_find_mountpoint(void)
-{
-	const char *ret;
-
-	if (tracefs_found)
-		return (const char *)tracefs_mountpoint;
-
-	ret = find_mountpoint("tracefs", (long) TRACEFS_MAGIC,
-			      tracefs_mountpoint, PATH_MAX + 1,
-			      tracefs_known_mountpoints);
-
-	if (ret)
-		tracefs_found = true;
-
-	return ret;
-}
-
-/* mount the tracefs somewhere if it's not mounted */
-char *tracefs_mount(const char *mountpoint)
-{
-	/* see if it's already mounted */
-	if (tracefs_find_mountpoint())
-		goto out;
-
-	/* if not mounted and no argument */
-	if (mountpoint == NULL) {
-		/* see if environment variable set */
-		mountpoint = getenv(PERF_TRACEFS_ENVIRONMENT);
-		/* if no environment variable, use default */
-		if (mountpoint == NULL)
-			mountpoint = TRACEFS_DEFAULT_PATH;
-	}
-
-	if (mount(NULL, mountpoint, "tracefs", 0, NULL) < 0)
-		return NULL;
-
-	/* save the mountpoint */
-	tracefs_found = true;
-	strncpy(tracefs_mountpoint, mountpoint, sizeof(tracefs_mountpoint));
-out:
-	return tracefs_mountpoint;
-}
diff --git a/tools/lib/api/fs/tracefs.h b/tools/lib/api/fs/tracefs.h
deleted file mode 100644
index da780ac..0000000
--- a/tools/lib/api/fs/tracefs.h
+++ /dev/null
@@ -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__ */

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [tip:perf/core] perf tools: Switch to tracing_path interface on appropriate places
  2015-09-02  7:56 ` [PATCH 15/15] perf tools: Switch to tracing_path interface on appropriate places Jiri Olsa
@ 2015-09-15  7:00   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-09-15  7:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, a.p.zijlstra, jolsa, dsahern, mingo, rostedt, acme, tglx,
	namhyung, matt, linux-kernel, raphael.beamonte

Commit-ID:  fbf99625b88fd8808bf2b80efac453d63cae08e8
Gitweb:     http://git.kernel.org/tip/fbf99625b88fd8808bf2b80efac453d63cae08e8
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Sep 2015 09:56:45 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-16-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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(-)

diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
index a38adf9..495d812 100644
--- a/tools/perf/tests/openat-syscall-all-cpus.c
+++ b/tools/perf/tests/openat-syscall-all-cpus.c
@@ -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;
 	}
 
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
index 8048c7d..08ac9d9 100644
--- a/tools/perf/tests/openat-syscall.c
+++ b/tools/perf/tests/openat-syscall.c
@@ -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;
 	}
 
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 91fbfd5..3a2ebe6 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -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);
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 499c83c..89dbeb9 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -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)

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-15  6:59   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
@ 2015-09-22  0:20     ` Vinson Lee
  2015-09-22 13:53       ` Arnaldo Carvalho de Melo
  2015-09-23  8:23       ` Matt Fleming
  0 siblings, 2 replies; 72+ messages in thread
From: Vinson Lee @ 2015-09-22  0:20 UTC (permalink / raw)
  To: rostedt, Jiri Olsa, matt, raphael.beamonte, H. Peter Anvin, LKML,
	Arnaldo Carvalho de Melo, Peter Zijlstra, David Ahern,
	Ingo Molnar, Thomas Gleixner, Namhyung Kim
  Cc: linux-tip-commits

On Mon, Sep 14, 2015 at 11:59 PM, tip-bot for Jiri Olsa
<tipbot@zytor.com> wrote:
> Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
> Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
> Author:     Jiri Olsa <jolsa@kernel.org>
> AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
> Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
> 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.
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Matt Fleming <matt@codeblueprint.co.uk>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Link: http://lkml.kernel.org/r/1441180605-24737-15-git-send-email-jolsa@kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-22  0:20     ` Vinson Lee
@ 2015-09-22 13:53       ` Arnaldo Carvalho de Melo
  2015-09-22 21:29         ` Vinson Lee
  2015-09-23  8:23       ` Matt Fleming
  1 sibling, 1 reply; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-22 13:53 UTC (permalink / raw)
  To: Vinson Lee
  Cc: rostedt, Jiri Olsa, matt, raphael.beamonte, H. Peter Anvin, LKML,
	Peter Zijlstra, David Ahern, Ingo Molnar, Thomas Gleixner,
	Namhyung Kim, linux-tip-commits, acme

Em Mon, Sep 21, 2015 at 05:20:03PM -0700, Vinson Lee escreveu:
> On Mon, Sep 14, 2015 at 11:59 PM, tip-bot for Jiri Olsa
> <tipbot@zytor.com> wrote:
> > Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
> > Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
> > Author:     Jiri Olsa <jolsa@kernel.org>
> > AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
> > Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
> > 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.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > Cc: David Ahern <dsahern@gmail.com>
> > Cc: Matt Fleming <matt@codeblueprint.co.uk>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Link: http://lkml.kernel.org/r/1441180605-24737-15-git-send-email-jolsa@kernel.org
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> 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>

Can you please check if this solves the problem?

- Arnaldo

diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c
index 7f73fa32a590..bcf5ec760eb9 100644
--- a/tools/vm/page-types.c
+++ b/tools/vm/page-types.c
@@ -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);

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-22 13:53       ` Arnaldo Carvalho de Melo
@ 2015-09-22 21:29         ` Vinson Lee
  0 siblings, 0 replies; 72+ messages in thread
From: Vinson Lee @ 2015-09-22 21:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: rostedt, Jiri Olsa, matt, raphael.beamonte, H. Peter Anvin, LKML,
	Peter Zijlstra, David Ahern, Ingo Molnar, Thomas Gleixner,
	Namhyung Kim, linux-tip-commits, Arnaldo Carvalho de Melo

On Tue, Sep 22, 2015 at 6:53 AM, Arnaldo Carvalho de Melo
<acme@redhat.com> wrote:
> Em Mon, Sep 21, 2015 at 05:20:03PM -0700, Vinson Lee escreveu:
>> On Mon, Sep 14, 2015 at 11:59 PM, tip-bot for Jiri Olsa
>> <tipbot@zytor.com> wrote:
>> > Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
>> > Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
>> > Author:     Jiri Olsa <jolsa@kernel.org>
>> > AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
>> > Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
>> > 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.
>> >
>> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>> > Cc: David Ahern <dsahern@gmail.com>
>> > Cc: Matt Fleming <matt@codeblueprint.co.uk>
>> > Cc: Namhyung Kim <namhyung@kernel.org>
>> > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
>> > Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
>> > Cc: Steven Rostedt <rostedt@goodmis.org>
>> > Link: http://lkml.kernel.org/r/1441180605-24737-15-git-send-email-jolsa@kernel.org
>> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>>
>> 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>
>
> Can you please check if this solves the problem?
>
> - Arnaldo
>
> diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c
> index 7f73fa32a590..bcf5ec760eb9 100644
> --- a/tools/vm/page-types.c
> +++ b/tools/vm/page-types.c
> @@ -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);


Yes, this patch fixes the build for me.

Vinson

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-22  0:20     ` Vinson Lee
  2015-09-22 13:53       ` Arnaldo Carvalho de Melo
@ 2015-09-23  8:23       ` Matt Fleming
  2015-09-23  8:39         ` Jiri Olsa
  1 sibling, 1 reply; 72+ messages in thread
From: Matt Fleming @ 2015-09-23  8:23 UTC (permalink / raw)
  To: Vinson Lee
  Cc: rostedt, Jiri Olsa, raphael.beamonte, H. Peter Anvin, LKML,
	Arnaldo Carvalho de Melo, Peter Zijlstra, David Ahern,
	Ingo Molnar, Thomas Gleixner, Namhyung Kim, linux-tip-commits

On Mon, 21 Sep, at 05:20:03PM, Vinson Lee wrote:
> On Mon, Sep 14, 2015 at 11:59 PM, tip-bot for Jiri Olsa
> <tipbot@zytor.com> wrote:
> > Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
> > Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
> > Author:     Jiri Olsa <jolsa@kernel.org>
> > AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
> > Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
> > 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.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > Cc: David Ahern <dsahern@gmail.com>
> > Cc: Matt Fleming <matt@codeblueprint.co.uk>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Link: http://lkml.kernel.org/r/1441180605-24737-15-git-send-email-jolsa@kernel.org
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> 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>

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?

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-23  8:23       ` Matt Fleming
@ 2015-09-23  8:39         ` Jiri Olsa
  2015-09-23 10:08           ` Matt Fleming
  2015-09-23 13:44           ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 72+ messages in thread
From: Jiri Olsa @ 2015-09-23  8:39 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Vinson Lee, rostedt, Jiri Olsa, raphael.beamonte, H. Peter Anvin,
	LKML, Arnaldo Carvalho de Melo, Peter Zijlstra, David Ahern,
	Ingo Molnar, Thomas Gleixner, Namhyung Kim, linux-tip-commits,
	Michael Petlan

On Wed, Sep 23, 2015 at 09:23:02AM +0100, Matt Fleming wrote:
> On Mon, 21 Sep, at 05:20:03PM, Vinson Lee wrote:
> > On Mon, Sep 14, 2015 at 11:59 PM, tip-bot for Jiri Olsa
> > <tipbot@zytor.com> wrote:
> > > Commit-ID:  60a1133a5b39738671eff1e4d77bedc1ee3fa528
> > > Gitweb:     http://git.kernel.org/tip/60a1133a5b39738671eff1e4d77bedc1ee3fa528
> > > Author:     Jiri Olsa <jolsa@kernel.org>
> > > AuthorDate: Wed, 2 Sep 2015 09:56:44 +0200
> > > Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
> > > 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.
> > >
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > Cc: David Ahern <dsahern@gmail.com>
> > > Cc: Matt Fleming <matt@codeblueprint.co.uk>
> > > Cc: Namhyung Kim <namhyung@kernel.org>
> > > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > > Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
> > > Cc: Steven Rostedt <rostedt@goodmis.org>
> > > Link: http://lkml.kernel.org/r/1441180605-24737-15-git-send-email-jolsa@kernel.org
> > > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > 
> > 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>
> 
> 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?

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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-23  8:39         ` Jiri Olsa
@ 2015-09-23 10:08           ` Matt Fleming
  2015-09-24 15:05             ` Michael Petlan
  2015-09-23 13:44           ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 72+ messages in thread
From: Matt Fleming @ 2015-09-23 10:08 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Vinson Lee, rostedt, Jiri Olsa, raphael.beamonte, H. Peter Anvin,
	LKML, Arnaldo Carvalho de Melo, Peter Zijlstra, David Ahern,
	Ingo Molnar, Thomas Gleixner, Namhyung Kim, linux-tip-commits,
	Michael Petlan, Andi Kleen

On Wed, 23 Sep, at 10:39:06AM, Jiri Olsa wrote:
> On Wed, Sep 23, 2015 at 09:23:02AM +0100, Matt Fleming wrote:
> > 
> > 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!

> 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.

> 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/1441479742-15402-1-git-send-email-matt@codeblueprint.co.uk

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-23  8:39         ` Jiri Olsa
  2015-09-23 10:08           ` Matt Fleming
@ 2015-09-23 13:44           ` Arnaldo Carvalho de Melo
  2015-09-23 13:50             ` Jiri Olsa
  2015-09-24 12:15             ` Matt Fleming
  1 sibling, 2 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-23 13:44 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Matt Fleming, Vinson Lee, rostedt, Jiri Olsa, raphael.beamonte,
	H. Peter Anvin, LKML, Peter Zijlstra, David Ahern, Ingo Molnar,
	Thomas Gleixner, Namhyung Kim, linux-tip-commits, Michael Petlan

Em Wed, Sep 23, 2015 at 10:39:06AM +0200, Jiri Olsa escreveu:
> On Wed, Sep 23, 2015 at 09:23:02AM +0100, Matt Fleming wrote:
> > On Mon, 21 Sep, at 05:20:03PM, Vinson Lee wrote:
> > > 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.

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-)

> > 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
 
> 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.
 
> 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-23 13:44           ` Arnaldo Carvalho de Melo
@ 2015-09-23 13:50             ` Jiri Olsa
  2015-09-23 13:54               ` Arnaldo Carvalho de Melo
  2015-09-24 12:15             ` Matt Fleming
  1 sibling, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2015-09-23 13:50 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Matt Fleming, Vinson Lee, rostedt, Jiri Olsa, raphael.beamonte,
	H. Peter Anvin, LKML, Peter Zijlstra, David Ahern, Ingo Molnar,
	Thomas Gleixner, Namhyung Kim, linux-tip-commits, Michael Petlan

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

SNIP

> 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
>  
> > 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.

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

jirka

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-23 13:50             ` Jiri Olsa
@ 2015-09-23 13:54               ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-23 13:54 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Matt Fleming, Vinson Lee, rostedt, Jiri Olsa, raphael.beamonte,
	H. Peter Anvin, LKML, Peter Zijlstra, David Ahern, Ingo Molnar,
	Thomas Gleixner, Namhyung Kim, linux-tip-commits, Michael Petlan

Em Wed, Sep 23, 2015 at 03:50:12PM +0200, Jiri Olsa escreveu:
> On Wed, Sep 23, 2015 at 10:44:56AM -0300, Arnaldo Carvalho de Melo wrote:
> 
> SNIP
> 
> > 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
> >  
> > > 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.
> 
> 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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-23 13:44           ` Arnaldo Carvalho de Melo
  2015-09-23 13:50             ` Jiri Olsa
@ 2015-09-24 12:15             ` Matt Fleming
  2015-09-24 14:29               ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 72+ messages in thread
From: Matt Fleming @ 2015-09-24 12:15 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Vinson Lee, rostedt, Jiri Olsa, raphael.beamonte,
	H. Peter Anvin, LKML, Peter Zijlstra, David Ahern, Ingo Molnar,
	Thomas Gleixner, Namhyung Kim, linux-tip-commits, Michael Petlan

On Wed, 23 Sep, at 10:44:56AM, Arnaldo Carvalho de Melo wrote:
> 
> 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!

> 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.

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-24 12:15             ` Matt Fleming
@ 2015-09-24 14:29               ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-24 14:29 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Jiri Olsa, Vinson Lee, rostedt, Jiri Olsa, raphael.beamonte,
	H. Peter Anvin, LKML, Peter Zijlstra, David Ahern, Ingo Molnar,
	Thomas Gleixner, Namhyung Kim, linux-tip-commits, Michael Petlan

Em Thu, Sep 24, 2015 at 01:15:51PM +0100, Matt Fleming escreveu:
> On Wed, 23 Sep, at 10:44:56AM, Arnaldo Carvalho de Melo wrote:
> > 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 :-)

> > 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.

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

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-23 10:08           ` Matt Fleming
@ 2015-09-24 15:05             ` Michael Petlan
  2015-10-07 20:10               ` Matt Fleming
  0 siblings, 1 reply; 72+ messages in thread
From: Michael Petlan @ 2015-09-24 15:05 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Jiri Olsa, Vinson Lee, rostedt, Jiri Olsa, raphael.beamonte,
	H. Peter Anvin, LKML, Arnaldo Carvalho de Melo, Peter Zijlstra,
	David Ahern, Ingo Molnar, Thomas Gleixner, Namhyung Kim,
	linux-tip-commits, Andi Kleen

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

[SNIP]

> > 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



^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-09-24 15:05             ` Michael Petlan
@ 2015-10-07 20:10               ` Matt Fleming
  2015-10-13 19:18                 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 72+ messages in thread
From: Matt Fleming @ 2015-10-07 20:10 UTC (permalink / raw)
  To: Michael Petlan
  Cc: Jiri Olsa, Vinson Lee, rostedt, Jiri Olsa, raphael.beamonte,
	H. Peter Anvin, LKML, Arnaldo Carvalho de Melo, Peter Zijlstra,
	David Ahern, Ingo Molnar, Thomas Gleixner, Namhyung Kim,
	linux-tip-commits, Andi Kleen

On Thu, 24 Sep, at 05:05:57PM, Michael Petlan wrote:
> 
> 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.

> 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.

> 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/1444056021-25721-1-git-send-email-matt@codeblueprint.co.uk  

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.

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [tip:perf/core] tools lib api fs: Remove debugfs, tracefs and findfs objects
  2015-10-07 20:10               ` Matt Fleming
@ 2015-10-13 19:18                 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-10-13 19:18 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Michael Petlan, Jiri Olsa, Vinson Lee, rostedt, Jiri Olsa,
	raphael.beamonte, H. Peter Anvin, LKML, Peter Zijlstra,
	David Ahern, Ingo Molnar, Thomas Gleixner, Namhyung Kim,
	linux-tip-commits, Andi Kleen

Em Wed, Oct 07, 2015 at 09:10:30PM +0100, Matt Fleming escreveu:
> On Thu, 24 Sep, at 05:05:57PM, Michael Petlan wrote:
> > 
> > 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.
> 
> > 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.
> 
> > 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
 
> 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/1444056021-25721-1-git-send-email-matt@codeblueprint.co.uk  
> 
> 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.
> 
> -- 
> Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 72+ messages in thread

end of thread, other threads:[~2015-10-13 19:18 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-02  7:56 [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa
2015-09-02  7:56 ` [PATCH 01/15] perf tools: Fix parse_events_add_pmu caller Jiri Olsa
2015-09-02 13:00   ` Arnaldo Carvalho de Melo
2015-09-02 13:34     ` Jiri Olsa
2015-09-05 14:00   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 02/15] perf tools: Remove mountpoint arg from perf_debugfs_mount Jiri Olsa
2015-09-08 14:32   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 03/15] perf tools: Move tracing_path stuff under same namespace Jiri Olsa
2015-09-08 14:33   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 04/15] perf tools: Move tracing_path interface into api/fs/tracing_path.c Jiri Olsa
2015-09-04 11:35   ` Matt Fleming
2015-09-04 13:28     ` Raphaël Beamonte
2015-09-08 14:33   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 05/15] tools lib api: Move debugfs__strerror_open into tracing_path.c object Jiri Olsa
2015-09-02 13:12   ` Arnaldo Carvalho de Melo
2015-09-04 11:36   ` Matt Fleming
2015-09-04 13:41   ` Raphaël Beamonte
2015-09-04 13:48     ` Jiri Olsa
2015-09-04 13:51       ` Raphaël Beamonte
2015-09-08 14:33   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 06/15] tools lib api: Make tracing_path_strerror_open message generic Jiri Olsa
2015-09-02 13:18   ` Arnaldo Carvalho de Melo
2015-09-02 13:44     ` Jiri Olsa
2015-09-02 14:16       ` Arnaldo Carvalho de Melo
2015-09-15  6:59   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 07/15] tools lib api: Add STR and PATH_MAX macros to fs object Jiri Olsa
2015-09-08 14:34   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 08/15] tools lib api: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c Jiri Olsa
2015-09-08 14:34   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 09/15] tools lib api: Add debugfs into fs.c object Jiri Olsa
2015-09-08 14:34   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 10/15] tools lib api: Add tracefs " Jiri Olsa
2015-09-08 14:35   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 11/15] tools lib api: Add mount support for fs Jiri Olsa
2015-09-04 14:14   ` Raphaël Beamonte
2015-09-04 14:20     ` Steven Rostedt
2015-09-04 14:26     ` Jiri Olsa
2015-09-04 14:57       ` Steven Rostedt
2015-09-04 15:00         ` Steven Rostedt
2015-09-04 15:12           ` Raphaël Beamonte
2015-09-08 14:35   ` [tip:perf/core] tools lib api fs: Add FSTYPE__mount() method tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 12/15] tools lib api: Add configured support for fs Jiri Olsa
2015-09-02 13:39   ` Arnaldo Carvalho de Melo
2015-09-02 13:41     ` Arnaldo Carvalho de Melo
2015-09-02 13:46     ` Jiri Olsa
2015-09-02 14:17       ` Arnaldo Carvalho de Melo
2015-09-02 16:52         ` Arnaldo Carvalho de Melo
2015-09-04  7:08           ` Jiri Olsa
2015-09-04 16:42             ` Arnaldo Carvalho de Melo
2015-09-04 17:45               ` Jiri Olsa
2015-09-08 14:35   ` [tip:perf/core] tools lib api fs: Add FSTYPE__configured() method tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 13/15] tools lib api: Replace debugfs/tracefs objects interface with fs.c Jiri Olsa
2015-09-15  6:59   ` [tip:perf/core] tools lib api fs: Replace debugfs/ tracefs " tip-bot for Jiri Olsa
2015-09-02  7:56 ` [PATCH 14/15] tools lib api: Remove debugfs, tracefs and findfs objects Jiri Olsa
2015-09-15  6:59   ` [tip:perf/core] tools lib api fs: " tip-bot for Jiri Olsa
2015-09-22  0:20     ` Vinson Lee
2015-09-22 13:53       ` Arnaldo Carvalho de Melo
2015-09-22 21:29         ` Vinson Lee
2015-09-23  8:23       ` Matt Fleming
2015-09-23  8:39         ` Jiri Olsa
2015-09-23 10:08           ` Matt Fleming
2015-09-24 15:05             ` Michael Petlan
2015-10-07 20:10               ` Matt Fleming
2015-10-13 19:18                 ` Arnaldo Carvalho de Melo
2015-09-23 13:44           ` Arnaldo Carvalho de Melo
2015-09-23 13:50             ` Jiri Olsa
2015-09-23 13:54               ` Arnaldo Carvalho de Melo
2015-09-24 12:15             ` Matt Fleming
2015-09-24 14:29               ` Arnaldo Carvalho de Melo
2015-09-02  7:56 ` [PATCH 15/15] perf tools: Switch to tracing_path interface on appropriate places Jiri Olsa
2015-09-15  7:00   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-09-02  8:01 ` [PATCH 00/15] perf tools: Cleanup filesystem api Jiri Olsa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.