diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-05-01 12:29:57 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-05-01 12:38:00 -0400 |
commit | 6eda5838bc5771578986429cde4a0870e1e5f5e1 (patch) | |
tree | 94b77643feda0d312bcd4c5b70fea8a268ef2f81 | |
parent | 3666932bf2212a8fa77e344c5d946e86787bdbbe (diff) |
perfcounter tools: move common defines ... to local header file
No change, move of duplicated stuff only.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | Documentation/perf_counter/Makefile | 1 | ||||
-rw-r--r-- | Documentation/perf_counter/builtin-record.c | 64 | ||||
-rw-r--r-- | Documentation/perf_counter/builtin-stat.c | 59 | ||||
-rw-r--r-- | Documentation/perf_counter/builtin-top.c | 63 | ||||
-rw-r--r-- | Documentation/perf_counter/perf.h | 64 |
5 files changed, 70 insertions, 181 deletions
diff --git a/Documentation/perf_counter/Makefile b/Documentation/perf_counter/Makefile index 877cf5dedb55..481e4c26cd45 100644 --- a/Documentation/perf_counter/Makefile +++ b/Documentation/perf_counter/Makefile | |||
@@ -287,6 +287,7 @@ export PERL_PATH | |||
287 | LIB_FILE=libperf.a | 287 | LIB_FILE=libperf.a |
288 | 288 | ||
289 | LIB_H += ../../include/linux/perf_counter.h | 289 | LIB_H += ../../include/linux/perf_counter.h |
290 | LIB_H += perf.h | ||
290 | LIB_H += util/levenshtein.h | 291 | LIB_H += util/levenshtein.h |
291 | LIB_H += util/parse-options.h | 292 | LIB_H += util/parse-options.h |
292 | LIB_H += util/quote.h | 293 | LIB_H += util/quote.h |
diff --git a/Documentation/perf_counter/builtin-record.c b/Documentation/perf_counter/builtin-record.c index 9cff266fb614..59f1d87f41e9 100644 --- a/Documentation/perf_counter/builtin-record.c +++ b/Documentation/perf_counter/builtin-record.c | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #define _GNU_SOURCE | 3 | #include "util/util.h" |
4 | |||
4 | #include <sys/types.h> | 5 | #include <sys/types.h> |
5 | #include <sys/stat.h> | 6 | #include <sys/stat.h> |
6 | #include <sys/time.h> | 7 | #include <sys/time.h> |
@@ -32,66 +33,7 @@ | |||
32 | 33 | ||
33 | #include "../../include/linux/perf_counter.h" | 34 | #include "../../include/linux/perf_counter.h" |
34 | 35 | ||
35 | 36 | #include "perf.h" | |
36 | /* | ||
37 | * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all | ||
38 | * counters in the current task. | ||
39 | */ | ||
40 | #define PR_TASK_PERF_COUNTERS_DISABLE 31 | ||
41 | #define PR_TASK_PERF_COUNTERS_ENABLE 32 | ||
42 | |||
43 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
44 | |||
45 | #define rdclock() \ | ||
46 | ({ \ | ||
47 | struct timespec ts; \ | ||
48 | \ | ||
49 | clock_gettime(CLOCK_MONOTONIC, &ts); \ | ||
50 | ts.tv_sec * 1000000000ULL + ts.tv_nsec; \ | ||
51 | }) | ||
52 | |||
53 | /* | ||
54 | * Pick up some kernel type conventions: | ||
55 | */ | ||
56 | #define __user | ||
57 | #define asmlinkage | ||
58 | |||
59 | #ifdef __x86_64__ | ||
60 | #define __NR_perf_counter_open 298 | ||
61 | #define rmb() asm volatile("lfence" ::: "memory") | ||
62 | #define cpu_relax() asm volatile("rep; nop" ::: "memory"); | ||
63 | #endif | ||
64 | |||
65 | #ifdef __i386__ | ||
66 | #define __NR_perf_counter_open 336 | ||
67 | #define rmb() asm volatile("lfence" ::: "memory") | ||
68 | #define cpu_relax() asm volatile("rep; nop" ::: "memory"); | ||
69 | #endif | ||
70 | |||
71 | #ifdef __powerpc__ | ||
72 | #define __NR_perf_counter_open 319 | ||
73 | #define rmb() asm volatile ("sync" ::: "memory") | ||
74 | #define cpu_relax() asm volatile ("" ::: "memory"); | ||
75 | #endif | ||
76 | |||
77 | #define unlikely(x) __builtin_expect(!!(x), 0) | ||
78 | #define min(x, y) ({ \ | ||
79 | typeof(x) _min1 = (x); \ | ||
80 | typeof(y) _min2 = (y); \ | ||
81 | (void) (&_min1 == &_min2); \ | ||
82 | _min1 < _min2 ? _min1 : _min2; }) | ||
83 | |||
84 | extern asmlinkage int sys_perf_counter_open( | ||
85 | struct perf_counter_hw_event *hw_event_uptr __user, | ||
86 | pid_t pid, | ||
87 | int cpu, | ||
88 | int group_fd, | ||
89 | unsigned long flags); | ||
90 | |||
91 | #define MAX_COUNTERS 64 | ||
92 | #define MAX_NR_CPUS 256 | ||
93 | |||
94 | #define EID(type, id) (((__u64)(type) << PERF_COUNTER_TYPE_SHIFT) | (id)) | ||
95 | 37 | ||
96 | static int nr_counters = 0; | 38 | static int nr_counters = 0; |
97 | static __u64 event_id[MAX_COUNTERS] = { }; | 39 | static __u64 event_id[MAX_COUNTERS] = { }; |
diff --git a/Documentation/perf_counter/builtin-stat.c b/Documentation/perf_counter/builtin-stat.c index 9fbc66173de7..6de38d256883 100644 --- a/Documentation/perf_counter/builtin-stat.c +++ b/Documentation/perf_counter/builtin-stat.c | |||
@@ -85,64 +85,7 @@ | |||
85 | 85 | ||
86 | #include "../../include/linux/perf_counter.h" | 86 | #include "../../include/linux/perf_counter.h" |
87 | 87 | ||
88 | 88 | #include "perf.h" | |
89 | /* | ||
90 | * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all | ||
91 | * counters in the current task. | ||
92 | */ | ||
93 | #define PR_TASK_PERF_COUNTERS_DISABLE 31 | ||
94 | #define PR_TASK_PERF_COUNTERS_ENABLE 32 | ||
95 | |||
96 | #define rdclock() \ | ||
97 | ({ \ | ||
98 | struct timespec ts; \ | ||
99 | \ | ||
100 | clock_gettime(CLOCK_MONOTONIC, &ts); \ | ||
101 | ts.tv_sec * 1000000000ULL + ts.tv_nsec; \ | ||
102 | }) | ||
103 | |||
104 | /* | ||
105 | * Pick up some kernel type conventions: | ||
106 | */ | ||
107 | #define __user | ||
108 | #define asmlinkage | ||
109 | |||
110 | #ifdef __x86_64__ | ||
111 | #define __NR_perf_counter_open 298 | ||
112 | #define rmb() asm volatile("lfence" ::: "memory") | ||
113 | #define cpu_relax() asm volatile("rep; nop" ::: "memory"); | ||
114 | #endif | ||
115 | |||
116 | #ifdef __i386__ | ||
117 | #define __NR_perf_counter_open 336 | ||
118 | #define rmb() asm volatile("lfence" ::: "memory") | ||
119 | #define cpu_relax() asm volatile("rep; nop" ::: "memory"); | ||
120 | #endif | ||
121 | |||
122 | #ifdef __powerpc__ | ||
123 | #define __NR_perf_counter_open 319 | ||
124 | #define rmb() asm volatile ("sync" ::: "memory") | ||
125 | #define cpu_relax() asm volatile ("" ::: "memory"); | ||
126 | #endif | ||
127 | |||
128 | #define unlikely(x) __builtin_expect(!!(x), 0) | ||
129 | #define min(x, y) ({ \ | ||
130 | typeof(x) _min1 = (x); \ | ||
131 | typeof(y) _min2 = (y); \ | ||
132 | (void) (&_min1 == &_min2); \ | ||
133 | _min1 < _min2 ? _min1 : _min2; }) | ||
134 | |||
135 | extern asmlinkage int sys_perf_counter_open( | ||
136 | struct perf_counter_hw_event *hw_event_uptr __user, | ||
137 | pid_t pid, | ||
138 | int cpu, | ||
139 | int group_fd, | ||
140 | unsigned long flags); | ||
141 | |||
142 | #define MAX_COUNTERS 64 | ||
143 | #define MAX_NR_CPUS 256 | ||
144 | |||
145 | #define EID(type, id) (((__u64)(type) << PERF_COUNTER_TYPE_SHIFT) | (id)) | ||
146 | 89 | ||
147 | static int system_wide = 0; | 90 | static int system_wide = 0; |
148 | 91 | ||
diff --git a/Documentation/perf_counter/builtin-top.c b/Documentation/perf_counter/builtin-top.c index b6d989e7b196..cd6f61d73418 100644 --- a/Documentation/perf_counter/builtin-top.c +++ b/Documentation/perf_counter/builtin-top.c | |||
@@ -66,68 +66,7 @@ | |||
66 | 66 | ||
67 | #include "../../include/linux/perf_counter.h" | 67 | #include "../../include/linux/perf_counter.h" |
68 | 68 | ||
69 | 69 | #include "perf.h" | |
70 | /* | ||
71 | * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all | ||
72 | * counters in the current task. | ||
73 | */ | ||
74 | #define PR_TASK_PERF_COUNTERS_DISABLE 31 | ||
75 | #define PR_TASK_PERF_COUNTERS_ENABLE 32 | ||
76 | |||
77 | #define rdclock() \ | ||
78 | ({ \ | ||
79 | struct timespec ts; \ | ||
80 | \ | ||
81 | clock_gettime(CLOCK_MONOTONIC, &ts); \ | ||
82 | ts.tv_sec * 1000000000ULL + ts.tv_nsec; \ | ||
83 | }) | ||
84 | |||
85 | /* | ||
86 | * Pick up some kernel type conventions: | ||
87 | */ | ||
88 | #define __user | ||
89 | #define asmlinkage | ||
90 | |||
91 | #ifdef __x86_64__ | ||
92 | #define __NR_perf_counter_open 298 | ||
93 | #define rmb() asm volatile("lfence" ::: "memory") | ||
94 | #define cpu_relax() asm volatile("rep; nop" ::: "memory"); | ||
95 | #endif | ||
96 | |||
97 | #ifdef __i386__ | ||
98 | #define __NR_perf_counter_open 336 | ||
99 | #define rmb() asm volatile("lfence" ::: "memory") | ||
100 | #define cpu_relax() asm volatile("rep; nop" ::: "memory"); | ||
101 | #endif | ||
102 | |||
103 | #ifdef __powerpc__ | ||
104 | #define __NR_perf_counter_open 319 | ||
105 | #define rmb() asm volatile ("sync" ::: "memory") | ||
106 | #define cpu_relax() asm volatile ("" ::: "memory"); | ||
107 | #endif | ||
108 | |||
109 | #define unlikely(x) __builtin_expect(!!(x), 0) | ||
110 | #define min(x, y) ({ \ | ||
111 | typeof(x) _min1 = (x); \ | ||
112 | typeof(y) _min2 = (y); \ | ||
113 | (void) (&_min1 == &_min2); \ | ||
114 | _min1 < _min2 ? _min1 : _min2; }) | ||
115 | |||
116 | asmlinkage int sys_perf_counter_open( | ||
117 | struct perf_counter_hw_event *hw_event_uptr __user, | ||
118 | pid_t pid, | ||
119 | int cpu, | ||
120 | int group_fd, | ||
121 | unsigned long flags) | ||
122 | { | ||
123 | return syscall( | ||
124 | __NR_perf_counter_open, hw_event_uptr, pid, cpu, group_fd, flags); | ||
125 | } | ||
126 | |||
127 | #define MAX_COUNTERS 64 | ||
128 | #define MAX_NR_CPUS 256 | ||
129 | |||
130 | #define EID(type, id) (((__u64)(type) << PERF_COUNTER_TYPE_SHIFT) | (id)) | ||
131 | 70 | ||
132 | static int system_wide = 0; | 71 | static int system_wide = 0; |
133 | 72 | ||
diff --git a/Documentation/perf_counter/perf.h b/Documentation/perf_counter/perf.h new file mode 100644 index 000000000000..391fcc73148a --- /dev/null +++ b/Documentation/perf_counter/perf.h | |||
@@ -0,0 +1,64 @@ | |||
1 | #ifndef _PERF_PERF_H | ||
2 | #define _PERF_PERF_H | ||
3 | |||
4 | /* | ||
5 | * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all | ||
6 | * counters in the current task. | ||
7 | */ | ||
8 | #define PR_TASK_PERF_COUNTERS_DISABLE 31 | ||
9 | #define PR_TASK_PERF_COUNTERS_ENABLE 32 | ||
10 | |||
11 | #define rdclock() \ | ||
12 | ({ \ | ||
13 | struct timespec ts; \ | ||
14 | \ | ||
15 | clock_gettime(CLOCK_MONOTONIC, &ts); \ | ||
16 | ts.tv_sec * 1000000000ULL + ts.tv_nsec; \ | ||
17 | }) | ||
18 | |||
19 | /* | ||
20 | * Pick up some kernel type conventions: | ||
21 | */ | ||
22 | #define __user | ||
23 | #define asmlinkage | ||
24 | |||
25 | #ifdef __x86_64__ | ||
26 | #define __NR_perf_counter_open 298 | ||
27 | #define rmb() asm volatile("lfence" ::: "memory") | ||
28 | #define cpu_relax() asm volatile("rep; nop" ::: "memory"); | ||
29 | #endif | ||
30 | |||
31 | #ifdef __i386__ | ||
32 | #define __NR_perf_counter_open 336 | ||
33 | #define rmb() asm volatile("lfence" ::: "memory") | ||
34 | #define cpu_relax() asm volatile("rep; nop" ::: "memory"); | ||
35 | #endif | ||
36 | |||
37 | #ifdef __powerpc__ | ||
38 | #define __NR_perf_counter_open 319 | ||
39 | #define rmb() asm volatile ("sync" ::: "memory") | ||
40 | #define cpu_relax() asm volatile ("" ::: "memory"); | ||
41 | #endif | ||
42 | |||
43 | #define unlikely(x) __builtin_expect(!!(x), 0) | ||
44 | #define min(x, y) ({ \ | ||
45 | typeof(x) _min1 = (x); \ | ||
46 | typeof(y) _min2 = (y); \ | ||
47 | (void) (&_min1 == &_min2); \ | ||
48 | _min1 < _min2 ? _min1 : _min2; }) | ||
49 | |||
50 | static inline int | ||
51 | sys_perf_counter_open(struct perf_counter_hw_event *hw_event_uptr, | ||
52 | pid_t pid, int cpu, int group_fd, | ||
53 | unsigned long flags) | ||
54 | { | ||
55 | return syscall(__NR_perf_counter_open, hw_event_uptr, pid, cpu, | ||
56 | group_fd, flags); | ||
57 | } | ||
58 | |||
59 | #define MAX_COUNTERS 64 | ||
60 | #define MAX_NR_CPUS 256 | ||
61 | |||
62 | #define EID(type, id) (((__u64)(type) << PERF_COUNTER_TYPE_SHIFT) | (id)) | ||
63 | |||
64 | #endif | ||