Commit-ID:  82baa0eb46c15b749723d0c801470fea044657d7
Gitweb:     http://git.kernel.org/tip/82baa0eb46c15b749723d0c801470fea044657d7
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 5 May 2014 12:58:31 +0200
Committer:  Jiri Olsa <[email protected]>
CommitDate: Mon, 5 May 2014 17:48:51 +0200

perf tools: Move sys_perf_event_open function from perf.h

Into perf-sys.h header, as requested by Peter:
  
http://lkml.kernel.org/r/[email protected]

Adding HAVE_ATTR_TEST define to turn off/on the attribute
test code in the sys_perf_event_open function.

Requested-by: Peter Zijlstra <[email protected]>
Acked-by: Arnaldo Carvalho de Melo <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: 
http://lkml.kernel.org/r/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
 tools/perf/perf-sys.h | 22 ++++++++++++++++++++++
 tools/perf/perf.h     | 40 +++++++++++-----------------------------
 2 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 4c22c2a..5268a14 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -1,6 +1,11 @@
 #ifndef _PERF_SYS_H
 #define _PERF_SYS_H
 
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <linux/types.h>
+#include <linux/perf_event.h>
 #include <asm/unistd.h>
 
 #if defined(__i386__)
@@ -165,4 +170,21 @@
 #define cpu_relax() barrier()
 #endif
 
+static inline int
+sys_perf_event_open(struct perf_event_attr *attr,
+                     pid_t pid, int cpu, int group_fd,
+                     unsigned long flags)
+{
+       int fd;
+
+       fd = syscall(__NR_perf_event_open, attr, pid, cpu,
+                    group_fd, flags);
+
+#ifdef HAVE_ATTR_TEST
+       if (unlikely(test_attr__enabled))
+               test_attr__open(attr, pid, cpu, fd, group_fd, flags);
+#endif
+       return fd;
+}
+
 #endif /* _PERF_SYS_H */
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index ee95965..813571b 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -1,18 +1,21 @@
 #ifndef _PERF_PERF_H
 #define _PERF_PERF_H
 
-#include "perf-sys.h"
-
-#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
-
 #include <time.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
+#include <stdbool.h>
 #include <linux/types.h>
 #include <linux/perf_event.h>
 
+extern bool test_attr__enabled;
+void test_attr__init(void);
+void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
+                    int fd, int group_fd, unsigned long flags);
+
+#define HAVE_ATTR_TEST
+#include "perf-sys.h"
+
+#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
+
 #ifndef NSEC_PER_SEC
 # define NSEC_PER_SEC                  1000000000ULL
 #endif
@@ -28,27 +31,6 @@ static inline unsigned long long rdclock(void)
        return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
 }
 
-extern bool test_attr__enabled;
-void test_attr__init(void);
-void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
-                    int fd, int group_fd, unsigned long flags);
-
-static inline int
-sys_perf_event_open(struct perf_event_attr *attr,
-                     pid_t pid, int cpu, int group_fd,
-                     unsigned long flags)
-{
-       int fd;
-
-       fd = syscall(__NR_perf_event_open, attr, pid, cpu,
-                    group_fd, flags);
-
-       if (unlikely(test_attr__enabled))
-               test_attr__open(attr, pid, cpu, fd, group_fd, flags);
-
-       return fd;
-}
-
 #define MAX_NR_CPUS                    256
 
 extern const char *input_name;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to