All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] perf: Have perf become tracefs aware
@ 2015-01-24 18:13 Steven Rostedt
  2015-01-24 18:13 ` [PATCH 1/5] tools lib fs: Add helper to find mounted file systems Steven Rostedt
                   ` (4 more replies)
  0 siblings, 5 replies; 25+ messages in thread
From: Steven Rostedt @ 2015-01-24 18:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Jiri Olsa, Arnaldo Carvalho de Melo,
	Masami Hiramatsu, Namhyung Kim


As I'm trying to move the tracing directory from debugfs, perf needs to
be aware of this as system admins will now be able to mount the tracing
directory without needing to mount debugfs. This patch series addresses
this and makes perf aware of tracefs.

I based this series on a recent tip branch: perf/core.

You can also get this series from my repo as stated below.


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
tip/perf/core

Head SHA1: 1a334ac9034ceefc1c87e4cd95c6e103ba29df44


Steven Rostedt (Red Hat) (5):
      tools lib fs: Add helper to find mounted file systems
      tools lib api fs: Add tracefs mount helper functions
      tools lib api fs: Add DEBUGFS_DEFAULT_PATH macro
      tools lib api fs: Add {tracefs,debugfs}_configured() functions
      perf: Make perf aware of tracefs

----
 tools/lib/api/Makefile                   |  4 ++
 tools/lib/api/fs/debugfs.c               | 68 ++++++++++----------------
 tools/lib/api/fs/debugfs.h               |  1 +
 tools/lib/api/fs/findfs.c                | 63 ++++++++++++++++++++++++
 tools/lib/api/fs/findfs.h                | 10 ++++
 tools/lib/api/fs/tracefs.c               | 84 ++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracefs.h               | 30 ++++++++++++
 tools/perf/tests/open-syscall-all-cpus.c |  7 ++-
 tools/perf/tests/open-syscall.c          |  7 ++-
 tools/perf/tests/parse-events.c          | 13 ++++-
 tools/perf/util/cache.h                  |  1 +
 tools/perf/util/evlist.c                 |  7 +--
 tools/perf/util/parse-events.c           | 15 ++++--
 tools/perf/util/parse-events.h           |  2 +-
 tools/perf/util/probe-event.c            | 24 ++++++---
 tools/perf/util/util.c                   | 60 ++++++++++++++++++-----
 tools/perf/util/util.h                   |  1 +
 17 files changed, 323 insertions(+), 74 deletions(-)

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

* [PATCH 1/5] tools lib fs: Add helper to find mounted file systems
  2015-01-24 18:13 [PATCH 0/5] perf: Have perf become tracefs aware Steven Rostedt
@ 2015-01-24 18:13 ` Steven Rostedt
  2015-01-25 16:41   ` Jiri Olsa
  2015-01-24 18:13 ` [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions Steven Rostedt
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2015-01-24 18:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Jiri Olsa, Arnaldo Carvalho de Melo,
	Masami Hiramatsu, Namhyung Kim

[-- Attachment #1: 0001-tools-lib-fs-Add-helper-to-find-mounted-file-systems.patch --]
[-- Type: text/plain, Size: 4960 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

In preparation for adding tracefs for perf to use, create a findfs
helper utility that find_debugfs uses instead of hard coding the search
in the code. This will allow for a find_tracefs to be used as well.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/lib/api/Makefile     |  2 ++
 tools/lib/api/fs/debugfs.c | 45 ++++-----------------------------
 tools/lib/api/fs/findfs.c  | 63 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/findfs.h  | 10 ++++++++
 4 files changed, 80 insertions(+), 40 deletions(-)
 create mode 100644 tools/lib/api/fs/findfs.c
 create mode 100644 tools/lib/api/fs/findfs.h

diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
index 36c08b1f4afb..22b2f15d7255 100644
--- a/tools/lib/api/Makefile
+++ b/tools/lib/api/Makefile
@@ -9,11 +9,13 @@ LIB_H=
 LIB_OBJS=
 
 LIB_H += fs/debugfs.h
+LIB_H += fs/findfs.h
 LIB_H += fs/fs.h
 # See comment below about piggybacking...
 LIB_H += fd/array.h
 
 LIB_OBJS += $(OUTPUT)fs/debugfs.o
+LIB_OBJS += $(OUTPUT)fs/findfs.o
 LIB_OBJS += $(OUTPUT)fs/fs.o
 # XXX piggybacking here, need to introduce libapikfd, or rename this
 # to plain libapik.a and make it have it all api goodies
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index a74fba6d7743..76eb92c0623f 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -8,6 +8,7 @@
 #include <linux/kernel.h>
 
 #include "debugfs.h"
+#include "findfs.h"
 
 char debugfs_mountpoint[PATH_MAX + 1] = "/sys/kernel/debug";
 
@@ -22,55 +23,19 @@ static bool debugfs_found;
 /* find the path to the mounted debugfs */
 const char *debugfs_find_mountpoint(void)
 {
-	const char * const *ptr;
-	char type[100];
-	FILE *fp;
-
 	if (debugfs_found)
 		return (const char *)debugfs_mountpoint;
 
-	ptr = debugfs_known_mountpoints;
-	while (*ptr) {
-		if (debugfs_valid_mountpoint(*ptr) == 0) {
-			debugfs_found = true;
-			strcpy(debugfs_mountpoint, *ptr);
-			return debugfs_mountpoint;
-		}
-		ptr++;
-	}
-
-	/* give up and parse /proc/mounts */
-	fp = fopen("/proc/mounts", "r");
-	if (fp == NULL)
-		return NULL;
-
-	while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
-		      debugfs_mountpoint, type) == 2) {
-		if (strcmp(type, "debugfs") == 0)
-			break;
-	}
-	fclose(fp);
-
-	if (strcmp(type, "debugfs") != 0)
-		return NULL;
-
-	debugfs_found = true;
-
-	return debugfs_mountpoint;
+	return find_mountpoint("debugfs", (long) DEBUGFS_MAGIC,
+			       debugfs_mountpoint, PATH_MAX + 1,
+			       debugfs_known_mountpoints);
 }
 
 /* verify that a mountpoint is actually a debugfs instance */
 
 int debugfs_valid_mountpoint(const char *debugfs)
 {
-	struct statfs st_fs;
-
-	if (statfs(debugfs, &st_fs) < 0)
-		return -ENOENT;
-	else if (st_fs.f_type != (long) DEBUGFS_MAGIC)
-		return -ENOENT;
-
-	return 0;
+	return valid_mountpoint(debugfs, (long) DEBUGFS_MAGIC);
 }
 
 /* mount the debugfs somewhere if it's not mounted */
diff --git a/tools/lib/api/fs/findfs.c b/tools/lib/api/fs/findfs.c
new file mode 100644
index 000000000000..fc62c84cc2e9
--- /dev/null
+++ b/tools/lib/api/fs/findfs.c
@@ -0,0 +1,63 @@
+#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 (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
new file mode 100644
index 000000000000..37bd7d94ce7e
--- /dev/null
+++ b/tools/lib/api/fs/findfs.h
@@ -0,0 +1,10 @@
+#ifndef __API_FINDFS_H__
+#define __API_FINDFS_H__
+
+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__ */
-- 
2.1.4



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

* [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-24 18:13 [PATCH 0/5] perf: Have perf become tracefs aware Steven Rostedt
  2015-01-24 18:13 ` [PATCH 1/5] tools lib fs: Add helper to find mounted file systems Steven Rostedt
@ 2015-01-24 18:13 ` Steven Rostedt
  2015-01-25 16:45   ` Jiri Olsa
                     ` (2 more replies)
  2015-01-24 18:13 ` [PATCH 3/5] tools lib api fs: Add DEBUGFS_DEFAULT_PATH macro Steven Rostedt
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 25+ messages in thread
From: Steven Rostedt @ 2015-01-24 18:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Jiri Olsa, Arnaldo Carvalho de Melo,
	Masami Hiramatsu, Namhyung Kim

[-- Attachment #1: 0002-tools-lib-api-fs-Add-tracefs-mount-helper-functions.patch --]
[-- Type: text/plain, Size: 4115 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Since tracefs will now hold the event directory for perf, and
even though by default, debugfs still mounts tracefs on the
debugfs/tracing directory, the system admin may now choose to not
mount debugfs and instead just mount tracefs instead.

Having tracefs helper functions will facilitate having perf look
for tracefs first, and then try debugfs as a fallback.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/lib/api/Makefile     |  2 ++
 tools/lib/api/fs/tracefs.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/lib/api/fs/tracefs.h | 29 +++++++++++++++++++
 3 files changed, 102 insertions(+)
 create mode 100644 tools/lib/api/fs/tracefs.c
 create mode 100644 tools/lib/api/fs/tracefs.h

diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
index 22b2f15d7255..212aa4fd65a0 100644
--- a/tools/lib/api/Makefile
+++ b/tools/lib/api/Makefile
@@ -9,12 +9,14 @@ LIB_H=
 LIB_OBJS=
 
 LIB_H += fs/debugfs.h
+LIB_H += fs/tracefs.h
 LIB_H += fs/findfs.h
 LIB_H += fs/fs.h
 # See comment below about piggybacking...
 LIB_H += fd/array.h
 
 LIB_OBJS += $(OUTPUT)fs/debugfs.o
+LIB_OBJS += $(OUTPUT)fs/tracefs.o
 LIB_OBJS += $(OUTPUT)fs/findfs.o
 LIB_OBJS += $(OUTPUT)fs/fs.o
 # XXX piggybacking here, need to introduce libapikfd, or rename this
diff --git a/tools/lib/api/fs/tracefs.c b/tools/lib/api/fs/tracefs.c
new file mode 100644
index 000000000000..bdaf54142c5d
--- /dev/null
+++ b/tools/lib/api/fs/tracefs.c
@@ -0,0 +1,71 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <sys/vfs.h>
+#include <sys/mount.h>
+#include <linux/kernel.h>
+
+#include "tracefs.h"
+#include "findfs.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;
+
+/* find the path to the mounted tracefs */
+const char *tracefs_find_mountpoint(void)
+{
+	if (tracefs_found)
+		return (const char *)tracefs_mountpoint;
+
+	return find_mountpoint("tracefs", (long) TRACEFS_MAGIC,
+			       tracefs_mountpoint, PATH_MAX + 1,
+			       tracefs_known_mountpoints);
+}
+
+/* verify that a mountpoint is actually a tracefs instance */
+
+int tracefs_valid_mountpoint(const char *tracefs)
+{
+	return valid_mountpoint(tracefs, (long) TRACEFS_MAGIC);
+}
+
+/* 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
new file mode 100644
index 000000000000..576206500e15
--- /dev/null
+++ b/tools/lib/api/fs/tracefs.h
@@ -0,0 +1,29 @@
+#ifndef __API_TRACEFS_H__
+#define __API_TRACEFS_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
+
+#ifndef TRACEFS_MAGIC
+#define TRACEFS_MAGIC          0x74726163
+#endif
+
+#ifndef PERF_TRACEFS_ENVIRONMENT
+#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
+#endif
+
+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.1.4



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

* [PATCH 3/5] tools lib api fs: Add DEBUGFS_DEFAULT_PATH macro
  2015-01-24 18:13 [PATCH 0/5] perf: Have perf become tracefs aware Steven Rostedt
  2015-01-24 18:13 ` [PATCH 1/5] tools lib fs: Add helper to find mounted file systems Steven Rostedt
  2015-01-24 18:13 ` [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions Steven Rostedt
@ 2015-01-24 18:13 ` Steven Rostedt
  2015-01-24 18:13 ` [PATCH 4/5] tools lib api fs: Add {tracefs,debugfs}_configured() functions Steven Rostedt
  2015-01-24 18:13 ` [PATCH 5/5] perf: Make perf aware of tracefs Steven Rostedt
  4 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2015-01-24 18:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Jiri Olsa, Arnaldo Carvalho de Melo,
	Masami Hiramatsu, Namhyung Kim

[-- Attachment #1: 0003-tools-lib-api-fs-Add-DEBUGFS_DEFAULT_PATH-macro.patch --]
[-- Type: text/plain, Size: 1239 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Instead of hard coding "/sys/kernel/debug" everywhere, create
a macro to hold where the default path exists.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/lib/api/fs/debugfs.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index 76eb92c0623f..1637e5b6a5d5 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -10,10 +10,14 @@
 #include "debugfs.h"
 #include "findfs.h"
 
-char debugfs_mountpoint[PATH_MAX + 1] = "/sys/kernel/debug";
+#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[] = {
-	"/sys/kernel/debug",
+	DEBUGFS_DEFAULT_PATH,
 	"/debug",
 	0,
 };
@@ -51,7 +55,7 @@ char *debugfs_mount(const char *mountpoint)
 		mountpoint = getenv(PERF_DEBUGFS_ENVIRONMENT);
 		/* if no environment variable, use default */
 		if (mountpoint == NULL)
-			mountpoint = "/sys/kernel/debug";
+			mountpoint = DEBUGFS_DEFAULT_PATH;
 	}
 
 	if (mount(NULL, mountpoint, "debugfs", 0, NULL) < 0)
-- 
2.1.4



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

* [PATCH 4/5] tools lib api fs: Add {tracefs,debugfs}_configured() functions
  2015-01-24 18:13 [PATCH 0/5] perf: Have perf become tracefs aware Steven Rostedt
                   ` (2 preceding siblings ...)
  2015-01-24 18:13 ` [PATCH 3/5] tools lib api fs: Add DEBUGFS_DEFAULT_PATH macro Steven Rostedt
@ 2015-01-24 18:13 ` Steven Rostedt
  2015-01-25 17:02   ` Jiri Olsa
  2015-01-24 18:13 ` [PATCH 5/5] perf: Make perf aware of tracefs Steven Rostedt
  4 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2015-01-24 18:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Jiri Olsa, Arnaldo Carvalho de Melo,
	Masami Hiramatsu, Namhyung Kim

[-- Attachment #1: 0004-tools-lib-api-fs-Add-tracefs-debugfs-_configured-fun.patch --]
[-- Type: text/plain, Size: 2894 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Add tracefs_configured() to return true if tracefs is configured in the
kernel (/sys/kernel/tracing exists), and debugfs_configured() if debugfs
is configured in the kernel (/sys/kernel/debug exists).

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/lib/api/fs/debugfs.c | 13 +++++++++++++
 tools/lib/api/fs/debugfs.h |  1 +
 tools/lib/api/fs/tracefs.c | 13 +++++++++++++
 tools/lib/api/fs/tracefs.h |  1 +
 4 files changed, 28 insertions(+)

diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index 1637e5b6a5d5..a2d8e59f042b 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -2,8 +2,11 @@
 #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>
 
@@ -24,6 +27,16 @@ static const char * const debugfs_known_mountpoints[] = {
 
 static bool debugfs_found;
 
+bool debugfs_configured(void)
+{
+	struct stat st;
+
+	if (stat(DEBUGFS_DEFAULT_PATH, &st) < 0)
+		return false;
+
+	return true;
+}
+
 /* find the path to the mounted debugfs */
 const char *debugfs_find_mountpoint(void)
 {
diff --git a/tools/lib/api/fs/debugfs.h b/tools/lib/api/fs/debugfs.h
index f19d3df9609d..a8a385008db3 100644
--- a/tools/lib/api/fs/debugfs.h
+++ b/tools/lib/api/fs/debugfs.h
@@ -20,6 +20,7 @@
 #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
 #endif
 
+bool debugfs_configured(void);
 const char *debugfs_find_mountpoint(void);
 int debugfs_valid_mountpoint(const char *debugfs);
 char *debugfs_mount(const char *mountpoint);
diff --git a/tools/lib/api/fs/tracefs.c b/tools/lib/api/fs/tracefs.c
index bdaf54142c5d..43cb0b24a999 100644
--- a/tools/lib/api/fs/tracefs.c
+++ b/tools/lib/api/fs/tracefs.c
@@ -2,8 +2,11 @@
 #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>
 
@@ -26,6 +29,16 @@ static const char * const tracefs_known_mountpoints[] = {
 
 static bool tracefs_found;
 
+bool tracefs_configured(void)
+{
+	struct stat st;
+
+	if (stat(TRACEFS_DEFAULT_PATH, &st) < 0)
+		return false;
+
+	return true;
+}
+
 /* find the path to the mounted tracefs */
 const char *tracefs_find_mountpoint(void)
 {
diff --git a/tools/lib/api/fs/tracefs.h b/tools/lib/api/fs/tracefs.h
index 576206500e15..a25a003a9ee6 100644
--- a/tools/lib/api/fs/tracefs.h
+++ b/tools/lib/api/fs/tracefs.h
@@ -20,6 +20,7 @@
 #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);
-- 
2.1.4



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

* [PATCH 5/5] perf: Make perf aware of tracefs
  2015-01-24 18:13 [PATCH 0/5] perf: Have perf become tracefs aware Steven Rostedt
                   ` (3 preceding siblings ...)
  2015-01-24 18:13 ` [PATCH 4/5] tools lib api fs: Add {tracefs,debugfs}_configured() functions Steven Rostedt
@ 2015-01-24 18:13 ` Steven Rostedt
  2015-01-25 13:50   ` Namhyung Kim
  2015-01-25 17:34   ` Jiri Olsa
  4 siblings, 2 replies; 25+ messages in thread
From: Steven Rostedt @ 2015-01-24 18:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Jiri Olsa, Arnaldo Carvalho de Melo,
	Masami Hiramatsu, Namhyung Kim

[-- Attachment #1: 0005-perf-Make-perf-aware-of-tracefs.patch --]
[-- Type: text/plain, Size: 12525 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

As tracefs may be mounted instead of debugfs to get to the event directories,
have perf know about tracefs, and use that file system over debugfs if it
is present.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/perf/tests/open-syscall-all-cpus.c |  7 +++-
 tools/perf/tests/open-syscall.c          |  7 +++-
 tools/perf/tests/parse-events.c          | 13 +++++--
 tools/perf/util/cache.h                  |  1 +
 tools/perf/util/evlist.c                 |  7 ++--
 tools/perf/util/parse-events.c           | 15 +++++---
 tools/perf/util/parse-events.h           |  2 +-
 tools/perf/util/probe-event.c            | 24 ++++++++-----
 tools/perf/util/util.c                   | 60 ++++++++++++++++++++++++++------
 tools/perf/util/util.h                   |  1 +
 10 files changed, 106 insertions(+), 31 deletions(-)

diff --git a/tools/perf/tests/open-syscall-all-cpus.c b/tools/perf/tests/open-syscall-all-cpus.c
index 8fa82d1700c7..21969e99ea46 100644
--- a/tools/perf/tests/open-syscall-all-cpus.c
+++ b/tools/perf/tests/open-syscall-all-cpus.c
@@ -29,7 +29,12 @@ int test__open_syscall_event_on_all_cpus(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
 	if (evsel == NULL) {
-		pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
+		if (tracefs_configured())
+			pr_debug("is tracefs mounted on /sys/kernel/debug?\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");
 		goto out_thread_map_delete;
 	}
 
diff --git a/tools/perf/tests/open-syscall.c b/tools/perf/tests/open-syscall.c
index a33b2daae40f..4250e40234d2 100644
--- a/tools/perf/tests/open-syscall.c
+++ b/tools/perf/tests/open-syscall.c
@@ -18,7 +18,12 @@ int test__open_syscall_event(void)
 
 	evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
 	if (evsel == NULL) {
-		pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
+		if (tracefs_configured())
+			pr_debug("is tracefs mounted on /sys/kernel/debug?\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");
 		goto out_thread_map_delete;
 	}
 
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 7f2f51f93619..ce474fba5a92 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -3,6 +3,7 @@
 #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"
@@ -1149,11 +1150,19 @@ static int count_tracepoints(void)
 {
 	char events_path[PATH_MAX];
 	struct dirent *events_ent;
+	const char *mountpoint;
 	DIR *events_dir;
 	int cnt = 0;
 
-	scnprintf(events_path, PATH_MAX, "%s/tracing/events",
-		  debugfs_find_mountpoint());
+	mountpoint = tracefs_find_mountpoint();
+	if (mountpoint) {
+		scnprintf(events_path, PATH_MAX, "%s/events",
+			  mountpoint);
+	} else {
+		mountpoint = debugfs_find_mountpoint();
+		scnprintf(events_path, PATH_MAX, "%s/tracing/events",
+			  mountpoint);
+	}
 
 	events_dir = opendir(events_path);
 
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 5cf9e1b5989d..99f7f8bd5fcd 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -17,6 +17,7 @@
 #define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
 #define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
 #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
+#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
 
 typedef int (*config_fn_t)(const char *, const char *, void *);
 extern int perf_default_config(const char *, const char *, void *);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index cbab1fb77b1d..cbe7ac93bedb 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1444,10 +1444,11 @@ int perf_evlist__strerror_tp(struct perf_evlist *evlist __maybe_unused,
 	switch (err) {
 	case ENOENT:
 		scnprintf(buf, size, "%s",
-			  "Error:\tUnable to find debugfs\n"
+			  "Error:\tUnable to find tracefs or debugfs\n"
 			  "Hint:\tWas your kernel was compiled with debugfs support?\n"
-			  "Hint:\tIs the debugfs filesystem mounted?\n"
-			  "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
+			  "Hint:\tIs the debugfs or tracefs filesystem mounted?\n"
+			  "Hint:\tTry 'sudo mount -t tracefs nodev /sys/kernel/tracing'\n"
+			  "Hint:\t or 'sudo mount -t debugfs nodev /sys/kernel/debug'");
 		break;
 	case EACCES:
 		scnprintf(buf, size,
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 77b43fe43d55..62f996aa1a28 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -30,6 +30,13 @@ extern int parse_events_debug;
 #endif
 int parse_events_parse(void *data, void *scanner);
 
+static int perf_valid_mountpoint(const char *fs)
+{
+	if (!tracefs_valid_mountpoint(fs))
+		return 0;
+	return debugfs_valid_mountpoint(fs);
+}
+
 static struct perf_pmu_event_symbol *perf_pmu_events_list;
 /*
  * The variable indicates the number of supported pmu event symbols.
@@ -175,7 +182,7 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
 	char evt_path[MAXPATHLEN];
 	char dir_path[MAXPATHLEN];
 
-	if (debugfs_valid_mountpoint(tracing_events_path))
+	if (perf_valid_mountpoint(tracing_events_path))
 		return NULL;
 
 	sys_dir = opendir(tracing_events_path);
@@ -475,7 +482,7 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
 {
 	int ret;
 
-	ret = debugfs_valid_mountpoint(tracing_events_path);
+	ret = perf_valid_mountpoint(tracing_events_path);
 	if (ret)
 		return ret;
 
@@ -1110,7 +1117,7 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
 	char dir_path[MAXPATHLEN];
 	char sbuf[STRERR_BUFSIZE];
 
-	if (debugfs_valid_mountpoint(tracing_events_path)) {
+	if (perf_valid_mountpoint(tracing_events_path)) {
 		printf("  [ Tracepoints not available: %s ]\n",
 			strerror_r(errno, sbuf, sizeof(sbuf)));
 		return;
@@ -1162,7 +1169,7 @@ int is_valid_tracepoint(const char *event_string)
 	char evt_path[MAXPATHLEN];
 	char dir_path[MAXPATHLEN];
 
-	if (debugfs_valid_mountpoint(tracing_events_path))
+	if (perf_valid_mountpoint(tracing_events_path))
 		return 0;
 
 	sys_dir = opendir(tracing_events_path);
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index db2cf78ff0f3..87e3434af124 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -121,6 +121,6 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
 int print_hwcache_events(const char *event_glob, bool name_only);
 extern int is_valid_tracepoint(const char *event_string);
 
-extern int valid_debugfs_mount(const char *debugfs);
+int valid_event_mount(const char *eventfs);
 
 #endif /* __PERF_PARSE_EVENTS_H */
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 7f9b8632e433..9f26913713b2 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -41,6 +41,7 @@
 #include "symbol.h"
 #include "thread.h"
 #include <api/fs/debugfs.h>
+#include <api/fs/tracefs.h>
 #include "trace-event.h"	/* For __maybe_unused */
 #include "probe-event.h"
 #include "probe-finder.h"
@@ -1805,7 +1806,7 @@ static void print_open_warning(int err, bool is_kprobe)
 			   " - please rebuild kernel with %s.\n",
 			   is_kprobe ? 'k' : 'u', config);
 	} else if (err == -ENOTSUP)
-		pr_warning("Debugfs is not mounted.\n");
+		pr_warning("Tracefs or debugfs is not mounted.\n");
 	else
 		pr_warning("Failed to open %cprobe_events: %s\n",
 			   is_kprobe ? 'k' : 'u',
@@ -1816,7 +1817,7 @@ static void print_both_open_warning(int kerr, int uerr)
 {
 	/* Both kprobes and uprobes are disabled, warn it. */
 	if (kerr == -ENOTSUP && uerr == -ENOTSUP)
-		pr_warning("Debugfs is not mounted.\n");
+		pr_warning("Tracefs or debugfs is not mounted.\n");
 	else if (kerr == -ENOENT && uerr == -ENOENT)
 		pr_warning("Please rebuild kernel with CONFIG_KPROBE_EVENTS "
 			   "or/and CONFIG_UPROBE_EVENTS.\n");
@@ -1833,13 +1834,20 @@ 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 = debugfs_find_mountpoint();
-	if (__debugfs == NULL)
-		return -ENOTSUP;
+	__debugfs = tracefs_find_mountpoint();
+	if (__debugfs == NULL) {
+		tracing_dir = "tracing/";
 
-	ret = e_snprintf(buf, PATH_MAX, "%s/%s", __debugfs, trace_file);
+		__debugfs = debugfs_find_mountpoint();
+		if (__debugfs == NULL)
+			return -ENOTSUP;
+	}
+
+	ret = e_snprintf(buf, PATH_MAX, "%s/%s%s",
+			 __debugfs, tracing_dir, trace_file);
 	if (ret >= 0) {
 		pr_debug("Opening %s write=%d\n", buf, readwrite);
 		if (readwrite && !probe_event_dry_run)
@@ -1855,12 +1863,12 @@ static int open_probe_events(const char *trace_file, bool readwrite)
 
 static int open_kprobe_events(bool readwrite)
 {
-	return open_probe_events("tracing/kprobe_events", readwrite);
+	return open_probe_events("kprobe_events", readwrite);
 }
 
 static int open_uprobe_events(bool readwrite)
 {
-	return open_probe_events("tracing/uprobe_events", readwrite);
+	return open_probe_events("uprobe_events", readwrite);
 }
 
 /* Get raw string list of current kprobe_events  or uprobe_events */
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index b86744f29eef..6fe49d4922f3 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -303,13 +303,26 @@ void set_term_quiet_input(struct termios *old)
 	tcsetattr(0, TCSANOW, &tc);
 }
 
-static void set_tracing_events_path(const char *mountpoint)
+static void set_tracing_events_path(const char *tracing, const char *mountpoint)
 {
-	snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s",
-		 mountpoint, "tracing/events");
+	snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
+		 mountpoint, tracing, "events");
 }
 
-const char *perf_debugfs_mount(const char *mountpoint)
+static const char *__perf_tracefs_mount(const char *mountpoint)
+{
+	const char *mnt;
+
+	mnt = tracefs_mount(mountpoint);
+	if (!mnt)
+		return NULL;
+
+	set_tracing_events_path("", mnt);
+
+	return mnt;
+}
+
+static const char *__perf_debugfs_mount(const char *mountpoint)
 {
 	const char *mnt;
 
@@ -317,7 +330,20 @@ const char *perf_debugfs_mount(const char *mountpoint)
 	if (!mnt)
 		return NULL;
 
-	set_tracing_events_path(mnt);
+	set_tracing_events_path("tracing/", mnt);
+
+	return mnt;
+}
+
+const char *perf_debugfs_mount(const char *mountpoint)
+{
+	const char *mnt;
+
+	mnt = __perf_tracefs_mount(mountpoint);
+	if (mnt)
+		return mnt;
+
+	mnt = __perf_debugfs_mount(mountpoint);
 
 	return mnt;
 }
@@ -325,12 +351,19 @@ const char *perf_debugfs_mount(const char *mountpoint)
 void perf_debugfs_set_path(const char *mntpt)
 {
 	snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt);
-	set_tracing_events_path(mntpt);
+	set_tracing_events_path("tracing/", mntpt);
+}
+
+static const char *find_tracefs(void)
+{
+	const char *path = __perf_tracefs_mount(NULL);
+
+	return path;
 }
 
 static const char *find_debugfs(void)
 {
-	const char *path = perf_debugfs_mount(NULL);
+	const char *path = __perf_debugfs_mount(NULL);
 
 	if (!path)
 		fprintf(stderr, "Your kernel does not support the debugfs filesystem");
@@ -344,6 +377,7 @@ static const char *find_debugfs(void)
  */
 const char *find_tracing_dir(void)
 {
+	const char *tracing_dir = "";
 	static char *tracing;
 	static int tracing_found;
 	const char *debugfs;
@@ -351,11 +385,15 @@ const char *find_tracing_dir(void)
 	if (tracing_found)
 		return tracing;
 
-	debugfs = find_debugfs();
-	if (!debugfs)
-		return NULL;
+	debugfs = find_tracefs();
+	if (!debugfs) {
+		tracing_dir = "/tracing";
+		debugfs = find_debugfs();
+		if (!debugfs)
+			return NULL;
+	}
 
-	if (asprintf(&tracing, "%s/tracing", debugfs) < 0)
+	if (asprintf(&tracing, "%s%s", tracing_dir, debugfs) < 0)
 		return NULL;
 
 	tracing_found = 1;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 027a5153495c..73c2f8e557ab 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -75,6 +75,7 @@
 #include <linux/types.h>
 #include <sys/ttydefaults.h>
 #include <api/fs/debugfs.h>
+#include <api/fs/tracefs.h>
 #include <termios.h>
 #include <linux/bitops.h>
 #include <termios.h>
-- 
2.1.4



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

* Re: [PATCH 5/5] perf: Make perf aware of tracefs
  2015-01-24 18:13 ` [PATCH 5/5] perf: Make perf aware of tracefs Steven Rostedt
@ 2015-01-25 13:50   ` Namhyung Kim
  2015-01-25 19:19     ` Steven Rostedt
  2015-01-25 17:34   ` Jiri Olsa
  1 sibling, 1 reply; 25+ messages in thread
From: Namhyung Kim @ 2015-01-25 13:50 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu

Hi Steve,

On Sat, Jan 24, 2015 at 01:13:35PM -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> 
> As tracefs may be mounted instead of debugfs to get to the event directories,
> have perf know about tracefs, and use that file system over debugfs if it
> is present.
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
>  const char *find_tracing_dir(void)
>  {
> +	const char *tracing_dir = "";
>  	static char *tracing;
>  	static int tracing_found;
>  	const char *debugfs;
> @@ -351,11 +385,15 @@ const char *find_tracing_dir(void)
>  	if (tracing_found)
>  		return tracing;
>  
> -	debugfs = find_debugfs();
> -	if (!debugfs)
> -		return NULL;
> +	debugfs = find_tracefs();
> +	if (!debugfs) {
> +		tracing_dir = "/tracing";
> +		debugfs = find_debugfs();
> +		if (!debugfs)
> +			return NULL;
> +	}
>  
> -	if (asprintf(&tracing, "%s/tracing", debugfs) < 0)
> +	if (asprintf(&tracing, "%s%s", tracing_dir, debugfs) < 0)

s/tracing_dir, debugfs/debugfs, tracing_dir/

Thanks,
Namhyung


>  		return NULL;
>  
>  	tracing_found = 1;
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 027a5153495c..73c2f8e557ab 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -75,6 +75,7 @@
>  #include <linux/types.h>
>  #include <sys/ttydefaults.h>
>  #include <api/fs/debugfs.h>
> +#include <api/fs/tracefs.h>
>  #include <termios.h>
>  #include <linux/bitops.h>
>  #include <termios.h>
> -- 
> 2.1.4
> 
> 

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

* Re: [PATCH 1/5] tools lib fs: Add helper to find mounted file systems
  2015-01-24 18:13 ` [PATCH 1/5] tools lib fs: Add helper to find mounted file systems Steven Rostedt
@ 2015-01-25 16:41   ` Jiri Olsa
  2015-01-25 19:20     ` Steven Rostedt
  0 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-01-25 16:41 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sat, Jan 24, 2015 at 01:13:31PM -0500, Steven Rostedt wrote:

SNIP

>  /* find the path to the mounted debugfs */
>  const char *debugfs_find_mountpoint(void)
>  {
> -	const char * const *ptr;
> -	char type[100];
> -	FILE *fp;
> -
>  	if (debugfs_found)
>  		return (const char *)debugfs_mountpoint;
>  
> -	ptr = debugfs_known_mountpoints;
> -	while (*ptr) {
> -		if (debugfs_valid_mountpoint(*ptr) == 0) {
> -			debugfs_found = true;
> -			strcpy(debugfs_mountpoint, *ptr);
> -			return debugfs_mountpoint;
> -		}
> -		ptr++;
> -	}
> -
> -	/* give up and parse /proc/mounts */
> -	fp = fopen("/proc/mounts", "r");
> -	if (fp == NULL)
> -		return NULL;
> -
> -	while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
> -		      debugfs_mountpoint, type) == 2) {
> -		if (strcmp(type, "debugfs") == 0)
> -			break;
> -	}
> -	fclose(fp);
> -
> -	if (strcmp(type, "debugfs") != 0)
> -		return NULL;
> -
> -	debugfs_found = true;
> -
> -	return debugfs_mountpoint;
> +	return find_mountpoint("debugfs", (long) DEBUGFS_MAGIC,
> +			       debugfs_mountpoint, PATH_MAX + 1,
> +			       debugfs_known_mountpoints);
>  }

debugfs_found is no longer set 'true' by debugfs_find_mountpoint

jirka

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-24 18:13 ` [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions Steven Rostedt
@ 2015-01-25 16:45   ` Jiri Olsa
  2015-01-25 19:22     ` Steven Rostedt
  2015-01-25 16:51   ` Jiri Olsa
  2015-01-25 16:56   ` Jiri Olsa
  2 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-01-25 16:45 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sat, Jan 24, 2015 at 01:13:32PM -0500, Steven Rostedt wrote:

SNIP

> diff --git a/tools/lib/api/fs/tracefs.h b/tools/lib/api/fs/tracefs.h
> new file mode 100644
> index 000000000000..576206500e15
> --- /dev/null
> +++ b/tools/lib/api/fs/tracefs.h
> @@ -0,0 +1,29 @@
> +#ifndef __API_TRACEFS_H__
> +#define __API_TRACEFS_H__
> +
> +#define _STR(x) #x
> +#define STR(x) _STR(x)

I can't find STR macro being used in the code..

jirka

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-24 18:13 ` [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions Steven Rostedt
  2015-01-25 16:45   ` Jiri Olsa
@ 2015-01-25 16:51   ` Jiri Olsa
  2015-01-25 19:24     ` Steven Rostedt
  2015-01-25 16:56   ` Jiri Olsa
  2 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-01-25 16:51 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sat, Jan 24, 2015 at 01:13:32PM -0500, Steven Rostedt wrote:

SNIP

> +static const char * const tracefs_known_mountpoints[] = {
> +	TRACEFS_DEFAULT_PATH,
> +	"/sys/kernel/debug/tracing",
> +	"/tracing",
> +	"/trace",
> +	0,
> +};
> +
> +static bool tracefs_found;
> +
> +/* find the path to the mounted tracefs */
> +const char *tracefs_find_mountpoint(void)
> +{
> +	if (tracefs_found)
> +		return (const char *)tracefs_mountpoint;
> +
> +	return find_mountpoint("tracefs", (long) TRACEFS_MAGIC,
> +			       tracefs_mountpoint, PATH_MAX + 1,
> +			       tracefs_known_mountpoints);
> +}

also tracefs_found is not set 'true' in case we succeed..

jirka

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-24 18:13 ` [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions Steven Rostedt
  2015-01-25 16:45   ` Jiri Olsa
  2015-01-25 16:51   ` Jiri Olsa
@ 2015-01-25 16:56   ` Jiri Olsa
  2015-01-25 19:26     ` Steven Rostedt
  2 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-01-25 16:56 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sat, Jan 24, 2015 at 01:13:32PM -0500, Steven Rostedt wrote:

SNIP

> @@ -0,0 +1,29 @@
> +#ifndef __API_TRACEFS_H__
> +#define __API_TRACEFS_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
> +
> +#ifndef TRACEFS_MAGIC
> +#define TRACEFS_MAGIC          0x74726163
> +#endif

I missed the point when tracefs became actual standalone
filesystem.. I'll check ;-)

Is it mutualy exclusive to 'debugfs/tracing' or those 2 can live together?

jirka

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

* Re: [PATCH 4/5] tools lib api fs: Add {tracefs,debugfs}_configured() functions
  2015-01-24 18:13 ` [PATCH 4/5] tools lib api fs: Add {tracefs,debugfs}_configured() functions Steven Rostedt
@ 2015-01-25 17:02   ` Jiri Olsa
  2015-01-25 19:27     ` Steven Rostedt
  0 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-01-25 17:02 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sat, Jan 24, 2015 at 01:13:34PM -0500, Steven Rostedt wrote:

SNIP

>  #include <sys/mount.h>
>  #include <linux/kernel.h>
>  
> @@ -24,6 +27,16 @@ static const char * const debugfs_known_mountpoints[] = {
>  
>  static bool debugfs_found;
>  
> +bool debugfs_configured(void)
> +{
> +	struct stat st;
> +
> +	if (stat(DEBUGFS_DEFAULT_PATH, &st) < 0)
> +		return false;
> +

hum, should  this function rather do

bool debugfs_configured(void)
{
	return debugfs_find_mountpoint() != NULL;
}


SNIP

>  static bool tracefs_found;
>  
> +bool tracefs_configured(void)
> +{
> +	struct stat st;
> +
> +	if (stat(TRACEFS_DEFAULT_PATH, &st) < 0)
> +		return false;
> +
> +	return true;
> +}

same for this one..

jirka

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

* Re: [PATCH 5/5] perf: Make perf aware of tracefs
  2015-01-24 18:13 ` [PATCH 5/5] perf: Make perf aware of tracefs Steven Rostedt
  2015-01-25 13:50   ` Namhyung Kim
@ 2015-01-25 17:34   ` Jiri Olsa
  2015-01-25 19:31     ` Steven Rostedt
  1 sibling, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-01-25 17:34 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sat, Jan 24, 2015 at 01:13:35PM -0500, Steven Rostedt wrote:

SNIP

> @@ -351,11 +385,15 @@ const char *find_tracing_dir(void)
>  	if (tracing_found)
>  		return tracing;
>  
> -	debugfs = find_debugfs();
> -	if (!debugfs)
> -		return NULL;
> +	debugfs = find_tracefs();
> +	if (!debugfs) {
> +		tracing_dir = "/tracing";
> +		debugfs = find_debugfs();
> +		if (!debugfs)
> +			return NULL;

so this pattern 'try tracefs, if that does not work try debugfs'
is all over the patch.. how about we add new new 'virtual' fs to
encapsulate that, like:

  with followign interface:
    bool tpfs_configured(void);
    const char *tpfs_find_mountpoint(void);
    int tpfs_valid_mountpoint(const char *debugfs);
    char *tpfs_mount(const char *mountpoint);
    extern char tpfs_mountpoint[];

It does not neceserily needs to reside in tools/lib/api/fs/tpfs.[ch],
but I believe we need some form of encapsulation for this.

jirka

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

* Re: [PATCH 5/5] perf: Make perf aware of tracefs
  2015-01-25 13:50   ` Namhyung Kim
@ 2015-01-25 19:19     ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2015-01-25 19:19 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu

On Sun, 25 Jan 2015 22:50:10 +0900
Namhyung Kim <namhyung@kernel.org> wrote:

> Hi Steve,
> 
> On Sat, Jan 24, 2015 at 01:13:35PM -0500, Steven Rostedt wrote:
> > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> > 
> > As tracefs may be mounted instead of debugfs to get to the event directories,
> > have perf know about tracefs, and use that file system over debugfs if it
> > is present.
> > 
> > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> > ---
> >  const char *find_tracing_dir(void)
> >  {
> > +	const char *tracing_dir = "";
> >  	static char *tracing;
> >  	static int tracing_found;
> >  	const char *debugfs;
> > @@ -351,11 +385,15 @@ const char *find_tracing_dir(void)
> >  	if (tracing_found)
> >  		return tracing;
> >  
> > -	debugfs = find_debugfs();
> > -	if (!debugfs)
> > -		return NULL;
> > +	debugfs = find_tracefs();
> > +	if (!debugfs) {
> > +		tracing_dir = "/tracing";
> > +		debugfs = find_debugfs();
> > +		if (!debugfs)
> > +			return NULL;
> > +	}
> >  
> > -	if (asprintf(&tracing, "%s/tracing", debugfs) < 0)
> > +	if (asprintf(&tracing, "%s%s", tracing_dir, debugfs) < 0)
> 
> s/tracing_dir, debugfs/debugfs, tracing_dir/

Hmm, I wonder how I missed this during testing. Ah, I think it broke on
tracefs, so I added this, but never tested it again without tracefs.

Thanks, will fix.

-- Steve

> 
> Thanks,
> Namhyung
> 
> 
> >  		return NULL;
> >  
> >  	tracing_found = 1;
> > diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> > index 027a5153495c..73c2f8e557ab 100644
> > --- a/tools/perf/util/util.h
> > +++ b/tools/perf/util/util.h
> > @@ -75,6 +75,7 @@
> >  #include <linux/types.h>
> >  #include <sys/ttydefaults.h>
> >  #include <api/fs/debugfs.h>
> > +#include <api/fs/tracefs.h>
> >  #include <termios.h>
> >  #include <linux/bitops.h>
> >  #include <termios.h>
> > -- 
> > 2.1.4
> > 
> > 


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

* Re: [PATCH 1/5] tools lib fs: Add helper to find mounted file systems
  2015-01-25 16:41   ` Jiri Olsa
@ 2015-01-25 19:20     ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2015-01-25 19:20 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sun, 25 Jan 2015 17:41:00 +0100
Jiri Olsa <jolsa@redhat.com> wrote:

> On Sat, Jan 24, 2015 at 01:13:31PM -0500, Steven Rostedt wrote:
> 

> > -	debugfs_found = true;
> > -
> > -	return debugfs_mountpoint;
> > +	return find_mountpoint("debugfs", (long) DEBUGFS_MAGIC,
> > +			       debugfs_mountpoint, PATH_MAX + 1,
> > +			       debugfs_known_mountpoints);
> >  }
> 
> debugfs_found is no longer set 'true' by debugfs_find_mountpoint
> 

Grumble. Will fix, thanks.

-- Steve

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-25 16:45   ` Jiri Olsa
@ 2015-01-25 19:22     ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2015-01-25 19:22 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sun, 25 Jan 2015 17:45:36 +0100
Jiri Olsa <jolsa@redhat.com> wrote:

> On Sat, Jan 24, 2015 at 01:13:32PM -0500, Steven Rostedt wrote:
> 
> SNIP
> 
> > diff --git a/tools/lib/api/fs/tracefs.h b/tools/lib/api/fs/tracefs.h
> > new file mode 100644
> > index 000000000000..576206500e15
> > --- /dev/null
> > +++ b/tools/lib/api/fs/tracefs.h
> > @@ -0,0 +1,29 @@
> > +#ifndef __API_TRACEFS_H__
> > +#define __API_TRACEFS_H__
> > +
> > +#define _STR(x) #x
> > +#define STR(x) _STR(x)
> 
> I can't find STR macro being used in the code..

I noticed this too just after I sent the series. I was seeing who had
good eyes ;-)

It's from doing a cut and paste from debugfs.h, which still has it,
even though after this series, it's only used by findfs.c. Thus it
should be moved to findfs.h, and removed from debugfs.h and tracefs.h.

Thanks, will fix.

-- Steve

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-25 16:51   ` Jiri Olsa
@ 2015-01-25 19:24     ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2015-01-25 19:24 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sun, 25 Jan 2015 17:51:14 +0100
Jiri Olsa <jolsa@redhat.com> wrote:

> On Sat, Jan 24, 2015 at 01:13:32PM -0500, Steven Rostedt wrote:
> 
> SNIP
> 
> > +static const char * const tracefs_known_mountpoints[] = {
> > +	TRACEFS_DEFAULT_PATH,
> > +	"/sys/kernel/debug/tracing",
> > +	"/tracing",
> > +	"/trace",
> > +	0,
> > +};
> > +
> > +static bool tracefs_found;
> > +
> > +/* find the path to the mounted tracefs */
> > +const char *tracefs_find_mountpoint(void)
> > +{
> > +	if (tracefs_found)
> > +		return (const char *)tracefs_mountpoint;
> > +
> > +	return find_mountpoint("tracefs", (long) TRACEFS_MAGIC,
> > +			       tracefs_mountpoint, PATH_MAX + 1,
> > +			       tracefs_known_mountpoints);
> > +}
> 
> also tracefs_found is not set 'true' in case we succeed..
> 

Thanks will fix. This is something that testing wouldn't catch, because
the tracefs_found (and debugfs_found) are just there to not try to
remount. Where here it would just refind where it is mounted. Thus, not
incorrect code, just inefficient code.

-- Steve

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-25 16:56   ` Jiri Olsa
@ 2015-01-25 19:26     ` Steven Rostedt
  2015-01-26  9:02       ` Jiri Olsa
  0 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2015-01-25 19:26 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sun, 25 Jan 2015 17:56:19 +0100
Jiri Olsa <jolsa@redhat.com> wrote:

> On Sat, Jan 24, 2015 at 01:13:32PM -0500, Steven Rostedt wrote:
> 
> SNIP
> 
> > @@ -0,0 +1,29 @@
> > +#ifndef __API_TRACEFS_H__
> > +#define __API_TRACEFS_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
> > +
> > +#ifndef TRACEFS_MAGIC
> > +#define TRACEFS_MAGIC          0x74726163
> > +#endif
> 
> I missed the point when tracefs became actual standalone
> filesystem.. I'll check ;-)
> 
> Is it mutualy exclusive to 'debugfs/tracing' or those 2 can live together?
> 

I'm working on the patches right now. But when it happens perf should
be aware of it. I already updated trace-cmd to be aware.

When tracefs is added, debugfs/tracing will automatically mount tracefs
when debugfs is mounted. As debugfs currently has some issues with
automounting, this part is being discussed currently as well.

Note, WTF is perf checking the magic number for debugfs?? If events
move, even if its at the same path, this will break perf!

-- Steve

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

* Re: [PATCH 4/5] tools lib api fs: Add {tracefs,debugfs}_configured() functions
  2015-01-25 17:02   ` Jiri Olsa
@ 2015-01-25 19:27     ` Steven Rostedt
  0 siblings, 0 replies; 25+ messages in thread
From: Steven Rostedt @ 2015-01-25 19:27 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sun, 25 Jan 2015 18:02:03 +0100
Jiri Olsa <jolsa@redhat.com> wrote:

> On Sat, Jan 24, 2015 at 01:13:34PM -0500, Steven Rostedt wrote:
> 
> SNIP
> 
> >  #include <sys/mount.h>
> >  #include <linux/kernel.h>
> >  
> > @@ -24,6 +27,16 @@ static const char * const debugfs_known_mountpoints[] = {
> >  
> >  static bool debugfs_found;
> >  
> > +bool debugfs_configured(void)
> > +{
> > +	struct stat st;
> > +
> > +	if (stat(DEBUGFS_DEFAULT_PATH, &st) < 0)
> > +		return false;
> > +
> 
> hum, should  this function rather do
> 
> bool debugfs_configured(void)
> {
> 	return debugfs_find_mountpoint() != NULL;
> }
> 
> 
> SNIP
> 
> >  static bool tracefs_found;
> >  
> > +bool tracefs_configured(void)
> > +{
> > +	struct stat st;
> > +
> > +	if (stat(TRACEFS_DEFAULT_PATH, &st) < 0)
> > +		return false;
> > +
> > +	return true;
> > +}
> 
> same for this one..


OK, will change.

-- Steve

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

* Re: [PATCH 5/5] perf: Make perf aware of tracefs
  2015-01-25 17:34   ` Jiri Olsa
@ 2015-01-25 19:31     ` Steven Rostedt
  2015-01-26  8:57       ` Jiri Olsa
  0 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2015-01-25 19:31 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sun, 25 Jan 2015 18:34:33 +0100
Jiri Olsa <jolsa@redhat.com> wrote:

> On Sat, Jan 24, 2015 at 01:13:35PM -0500, Steven Rostedt wrote:
> 
> SNIP
> 
> > @@ -351,11 +385,15 @@ const char *find_tracing_dir(void)
> >  	if (tracing_found)
> >  		return tracing;
> >  
> > -	debugfs = find_debugfs();
> > -	if (!debugfs)
> > -		return NULL;
> > +	debugfs = find_tracefs();
> > +	if (!debugfs) {
> > +		tracing_dir = "/tracing";
> > +		debugfs = find_debugfs();
> > +		if (!debugfs)
> > +			return NULL;
> 
> so this pattern 'try tracefs, if that does not work try debugfs'
> is all over the patch.. how about we add new new 'virtual' fs to
> encapsulate that, like:
> 
>   with followign interface:
>     bool tpfs_configured(void);
>     const char *tpfs_find_mountpoint(void);
>     int tpfs_valid_mountpoint(const char *debugfs);
>     char *tpfs_mount(const char *mountpoint);
>     extern char tpfs_mountpoint[];
> 
> It does not neceserily needs to reside in tools/lib/api/fs/tpfs.[ch],
> but I believe we need some form of encapsulation for this.

I did it this way because perf had no encapsulation for finding debugfs
paths. I made the change in trace-cmd in one location. Perf does it a
little different in each place. I have no idea why there was more than
one location slapping on "/tracing".

I'd like to get tracefs into perf before doing any redesign of perf's
infrastructure. That could come later as a cleanup.

This is not a fast path, it wont hurt performance. I agree it should be
encapsulated, but that's going outside of the scope of this patch
series, which is only to add awareness to tracefs, not to clean up
perf's access to the debugfs/tracing directory.

-- Steve

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

* Re: [PATCH 5/5] perf: Make perf aware of tracefs
  2015-01-25 19:31     ` Steven Rostedt
@ 2015-01-26  8:57       ` Jiri Olsa
  0 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-01-26  8:57 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sun, Jan 25, 2015 at 02:31:51PM -0500, Steven Rostedt wrote:
> On Sun, 25 Jan 2015 18:34:33 +0100
> Jiri Olsa <jolsa@redhat.com> wrote:
> 
> > On Sat, Jan 24, 2015 at 01:13:35PM -0500, Steven Rostedt wrote:
> > 
> > SNIP
> > 
> > > @@ -351,11 +385,15 @@ const char *find_tracing_dir(void)
> > >  	if (tracing_found)
> > >  		return tracing;
> > >  
> > > -	debugfs = find_debugfs();
> > > -	if (!debugfs)
> > > -		return NULL;
> > > +	debugfs = find_tracefs();
> > > +	if (!debugfs) {
> > > +		tracing_dir = "/tracing";
> > > +		debugfs = find_debugfs();
> > > +		if (!debugfs)
> > > +			return NULL;
> > 
> > so this pattern 'try tracefs, if that does not work try debugfs'
> > is all over the patch.. how about we add new new 'virtual' fs to
> > encapsulate that, like:
> > 
> >   with followign interface:
> >     bool tpfs_configured(void);
> >     const char *tpfs_find_mountpoint(void);
> >     int tpfs_valid_mountpoint(const char *debugfs);
> >     char *tpfs_mount(const char *mountpoint);
> >     extern char tpfs_mountpoint[];
> > 
> > It does not neceserily needs to reside in tools/lib/api/fs/tpfs.[ch],
> > but I believe we need some form of encapsulation for this.
> 
> I did it this way because perf had no encapsulation for finding debugfs
> paths. I made the change in trace-cmd in one location. Perf does it a
> little different in each place. I have no idea why there was more than
> one location slapping on "/tracing".
> 
> I'd like to get tracefs into perf before doing any redesign of perf's
> infrastructure. That could come later as a cleanup.
> 
> This is not a fast path, it wont hurt performance. I agree it should be
> encapsulated, but that's going outside of the scope of this patch
> series, which is only to add awareness to tracefs, not to clean up
> perf's access to the debugfs/tracing directory.

sure, np.. it could be taken care of later

jirka

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-25 19:26     ` Steven Rostedt
@ 2015-01-26  9:02       ` Jiri Olsa
  2015-01-26 14:26         ` Steven Rostedt
  0 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-01-26  9:02 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Sun, Jan 25, 2015 at 02:26:45PM -0500, Steven Rostedt wrote:
> On Sun, 25 Jan 2015 17:56:19 +0100
> Jiri Olsa <jolsa@redhat.com> wrote:
> 
> > On Sat, Jan 24, 2015 at 01:13:32PM -0500, Steven Rostedt wrote:
> > 
> > SNIP
> > 
> > > @@ -0,0 +1,29 @@
> > > +#ifndef __API_TRACEFS_H__
> > > +#define __API_TRACEFS_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
> > > +
> > > +#ifndef TRACEFS_MAGIC
> > > +#define TRACEFS_MAGIC          0x74726163
> > > +#endif
> > 
> > I missed the point when tracefs became actual standalone
> > filesystem.. I'll check ;-)
> > 
> > Is it mutualy exclusive to 'debugfs/tracing' or those 2 can live together?
> > 
> 
> I'm working on the patches right now. But when it happens perf should
> be aware of it. I already updated trace-cmd to be aware.
> 
> When tracefs is added, debugfs/tracing will automatically mount tracefs
> when debugfs is mounted. As debugfs currently has some issues with
> automounting, this part is being discussed currently as well.
> 
> Note, WTF is perf checking the magic number for debugfs?? If events
> move, even if its at the same path, this will break perf!

good question.. it's there since 2009:
  f6bdafef2ab9 perf_counter: Add tracepoint support to perf list, perf stat

I guess we didn't want anyone to trick us with fake tracepoints ;-)

jirka

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-26  9:02       ` Jiri Olsa
@ 2015-01-26 14:26         ` Steven Rostedt
  2015-01-26 14:31           ` Jiri Olsa
  0 siblings, 1 reply; 25+ messages in thread
From: Steven Rostedt @ 2015-01-26 14:26 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Mon, 26 Jan 2015 10:02:55 +0100
Jiri Olsa <jolsa@redhat.com> wrote:

> > Note, WTF is perf checking the magic number for debugfs?? If events
> > move, even if its at the same path, this will break perf!
> 
> good question.. it's there since 2009:
>   f6bdafef2ab9 perf_counter: Add tracepoint support to perf list, perf stat
> 
> I guess we didn't want anyone to trick us with fake tracepoints ;-)

But that would be a feature not a bug. I could imagine admins doing
this for some work around.

But can we nuke that check? I don't think it's very useful.

-- Steve

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-26 14:26         ` Steven Rostedt
@ 2015-01-26 14:31           ` Jiri Olsa
  2015-01-26 14:44             ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-01-26 14:31 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Jiri Olsa,
	Arnaldo Carvalho de Melo, Masami Hiramatsu, Namhyung Kim

On Mon, Jan 26, 2015 at 09:26:21AM -0500, Steven Rostedt wrote:
> On Mon, 26 Jan 2015 10:02:55 +0100
> Jiri Olsa <jolsa@redhat.com> wrote:
> 
> > > Note, WTF is perf checking the magic number for debugfs?? If events
> > > move, even if its at the same path, this will break perf!
> > 
> > good question.. it's there since 2009:
> >   f6bdafef2ab9 perf_counter: Add tracepoint support to perf list, perf stat
> > 
> > I guess we didn't want anyone to trick us with fake tracepoints ;-)
> 
> But that would be a feature not a bug. I could imagine admins doing
> this for some work around.
> 
> But can we nuke that check? I don't think it's very useful.

I'd be ok with that

jirka

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

* Re: [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions
  2015-01-26 14:31           ` Jiri Olsa
@ 2015-01-26 14:44             ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 25+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-01-26 14:44 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Steven Rostedt, linux-kernel, Ingo Molnar, Andrew Morton,
	Jiri Olsa, Masami Hiramatsu, Namhyung Kim

Em Mon, Jan 26, 2015 at 03:31:48PM +0100, Jiri Olsa escreveu:
> On Mon, Jan 26, 2015 at 09:26:21AM -0500, Steven Rostedt wrote:
> > On Mon, 26 Jan 2015 10:02:55 +0100
> > Jiri Olsa <jolsa@redhat.com> wrote:
> > 
> > > > Note, WTF is perf checking the magic number for debugfs?? If events
> > > > move, even if its at the same path, this will break perf!
> > > 
> > > good question.. it's there since 2009:
> > >   f6bdafef2ab9 perf_counter: Add tracepoint support to perf list, perf stat
> > > 
> > > I guess we didn't want anyone to trick us with fake tracepoints ;-)
> > 
> > But that would be a feature not a bug. I could imagine admins doing
> > this for some work around.
> > 
> > But can we nuke that check? I don't think it's very useful.
> 
> I'd be ok with that

Yeah, that check is a nuisance, should be removed as it takes away
flexibility...

- Arnaldo

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

end of thread, other threads:[~2015-01-26 14:44 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-24 18:13 [PATCH 0/5] perf: Have perf become tracefs aware Steven Rostedt
2015-01-24 18:13 ` [PATCH 1/5] tools lib fs: Add helper to find mounted file systems Steven Rostedt
2015-01-25 16:41   ` Jiri Olsa
2015-01-25 19:20     ` Steven Rostedt
2015-01-24 18:13 ` [PATCH 2/5] tools lib api fs: Add tracefs mount helper functions Steven Rostedt
2015-01-25 16:45   ` Jiri Olsa
2015-01-25 19:22     ` Steven Rostedt
2015-01-25 16:51   ` Jiri Olsa
2015-01-25 19:24     ` Steven Rostedt
2015-01-25 16:56   ` Jiri Olsa
2015-01-25 19:26     ` Steven Rostedt
2015-01-26  9:02       ` Jiri Olsa
2015-01-26 14:26         ` Steven Rostedt
2015-01-26 14:31           ` Jiri Olsa
2015-01-26 14:44             ` Arnaldo Carvalho de Melo
2015-01-24 18:13 ` [PATCH 3/5] tools lib api fs: Add DEBUGFS_DEFAULT_PATH macro Steven Rostedt
2015-01-24 18:13 ` [PATCH 4/5] tools lib api fs: Add {tracefs,debugfs}_configured() functions Steven Rostedt
2015-01-25 17:02   ` Jiri Olsa
2015-01-25 19:27     ` Steven Rostedt
2015-01-24 18:13 ` [PATCH 5/5] perf: Make perf aware of tracefs Steven Rostedt
2015-01-25 13:50   ` Namhyung Kim
2015-01-25 19:19     ` Steven Rostedt
2015-01-25 17:34   ` Jiri Olsa
2015-01-25 19:31     ` Steven Rostedt
2015-01-26  8:57       ` 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.