]> git.karo-electronics.de Git - linux-beck.git/commitdiff
perf tools: Move sys_perf_event_open function from perf.h
authorJiri Olsa <jolsa@kernel.org>
Mon, 5 May 2014 10:58:31 +0000 (12:58 +0200)
committerJiri Olsa <jolsa@kernel.org>
Mon, 5 May 2014 15:48:51 +0000 (17:48 +0200)
Into perf-sys.h header, as requested by Peter:
  http://lkml.kernel.org/r/20140502115201.GI30445@twins.programming.kicks-ass.net

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

Requested-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1399293219-8732-10-git-send-email-jolsa@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
tools/perf/perf-sys.h
tools/perf/perf.h

index 4c22c2a66b6ce78c5392ddff91bbfaf723dbce4e..5268a1481d23287a5d97ac791bc63283f2945d7e 100644 (file)
@@ -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__)
 #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 */
index ee959659b778b4a238cd0ab760003f3be917c382..813571b07246b694d7595195f568bd788f219fbb 100644 (file)
@@ -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;