diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-05-05 06:58:31 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-05-05 11:48:51 -0400 |
commit | 82baa0eb46c15b749723d0c801470fea044657d7 (patch) | |
tree | 97781ce38bb6eb3496dc49cb62094d097466de60 /tools/perf | |
parent | 43599d1f7adffbbf990b00716ba22974ec1487be (diff) |
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/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>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/perf-sys.h | 22 | ||||
-rw-r--r-- | 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 4c22c2a66b6c..5268a1481d23 100644 --- a/tools/perf/perf-sys.h +++ b/tools/perf/perf-sys.h | |||
@@ -1,6 +1,11 @@ | |||
1 | #ifndef _PERF_SYS_H | 1 | #ifndef _PERF_SYS_H |
2 | #define _PERF_SYS_H | 2 | #define _PERF_SYS_H |
3 | 3 | ||
4 | #include <unistd.h> | ||
5 | #include <sys/types.h> | ||
6 | #include <sys/syscall.h> | ||
7 | #include <linux/types.h> | ||
8 | #include <linux/perf_event.h> | ||
4 | #include <asm/unistd.h> | 9 | #include <asm/unistd.h> |
5 | 10 | ||
6 | #if defined(__i386__) | 11 | #if defined(__i386__) |
@@ -165,4 +170,21 @@ | |||
165 | #define cpu_relax() barrier() | 170 | #define cpu_relax() barrier() |
166 | #endif | 171 | #endif |
167 | 172 | ||
173 | static inline int | ||
174 | sys_perf_event_open(struct perf_event_attr *attr, | ||
175 | pid_t pid, int cpu, int group_fd, | ||
176 | unsigned long flags) | ||
177 | { | ||
178 | int fd; | ||
179 | |||
180 | fd = syscall(__NR_perf_event_open, attr, pid, cpu, | ||
181 | group_fd, flags); | ||
182 | |||
183 | #ifdef HAVE_ATTR_TEST | ||
184 | if (unlikely(test_attr__enabled)) | ||
185 | test_attr__open(attr, pid, cpu, fd, group_fd, flags); | ||
186 | #endif | ||
187 | return fd; | ||
188 | } | ||
189 | |||
168 | #endif /* _PERF_SYS_H */ | 190 | #endif /* _PERF_SYS_H */ |
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index ee959659b778..813571b07246 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
@@ -1,18 +1,21 @@ | |||
1 | #ifndef _PERF_PERF_H | 1 | #ifndef _PERF_PERF_H |
2 | #define _PERF_PERF_H | 2 | #define _PERF_PERF_H |
3 | 3 | ||
4 | #include "perf-sys.h" | ||
5 | |||
6 | #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) | ||
7 | |||
8 | #include <time.h> | 4 | #include <time.h> |
9 | #include <unistd.h> | 5 | #include <stdbool.h> |
10 | #include <sys/types.h> | ||
11 | #include <sys/syscall.h> | ||
12 | |||
13 | #include <linux/types.h> | 6 | #include <linux/types.h> |
14 | #include <linux/perf_event.h> | 7 | #include <linux/perf_event.h> |
15 | 8 | ||
9 | extern bool test_attr__enabled; | ||
10 | void test_attr__init(void); | ||
11 | void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, | ||
12 | int fd, int group_fd, unsigned long flags); | ||
13 | |||
14 | #define HAVE_ATTR_TEST | ||
15 | #include "perf-sys.h" | ||
16 | |||
17 | #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) | ||
18 | |||
16 | #ifndef NSEC_PER_SEC | 19 | #ifndef NSEC_PER_SEC |
17 | # define NSEC_PER_SEC 1000000000ULL | 20 | # define NSEC_PER_SEC 1000000000ULL |
18 | #endif | 21 | #endif |
@@ -28,27 +31,6 @@ static inline unsigned long long rdclock(void) | |||
28 | return ts.tv_sec * 1000000000ULL + ts.tv_nsec; | 31 | return ts.tv_sec * 1000000000ULL + ts.tv_nsec; |
29 | } | 32 | } |
30 | 33 | ||
31 | extern bool test_attr__enabled; | ||
32 | void test_attr__init(void); | ||
33 | void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, | ||
34 | int fd, int group_fd, unsigned long flags); | ||
35 | |||
36 | static inline int | ||
37 | sys_perf_event_open(struct perf_event_attr *attr, | ||
38 | pid_t pid, int cpu, int group_fd, | ||
39 | unsigned long flags) | ||
40 | { | ||
41 | int fd; | ||
42 | |||
43 | fd = syscall(__NR_perf_event_open, attr, pid, cpu, | ||
44 | group_fd, flags); | ||
45 | |||
46 | if (unlikely(test_attr__enabled)) | ||
47 | test_attr__open(attr, pid, cpu, fd, group_fd, flags); | ||
48 | |||
49 | return fd; | ||
50 | } | ||
51 | |||
52 | #define MAX_NR_CPUS 256 | 34 | #define MAX_NR_CPUS 256 |
53 | 35 | ||
54 | extern const char *input_name; | 36 | extern const char *input_name; |