4 #include <asm/unistd.h>
7 #define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
8 #define cpu_relax() asm volatile("rep; nop" ::: "memory");
9 #define CPUINFO_PROC "model name"
10 #ifndef __NR_perf_event_open
11 # define __NR_perf_event_open 336
15 #if defined(__x86_64__)
16 #define rmb() asm volatile("lfence" ::: "memory")
17 #define cpu_relax() asm volatile("rep; nop" ::: "memory");
18 #define CPUINFO_PROC "model name"
19 #ifndef __NR_perf_event_open
20 # define __NR_perf_event_open 298
25 #include "../../arch/powerpc/include/uapi/asm/unistd.h"
26 #define rmb() asm volatile ("sync" ::: "memory")
27 #define cpu_relax() asm volatile ("" ::: "memory");
28 #define CPUINFO_PROC "cpu"
32 #define rmb() asm volatile("bcr 15,0" ::: "memory")
33 #define cpu_relax() asm volatile("" ::: "memory");
37 #if defined(__SH4A__) || defined(__SH5__)
38 # define rmb() asm volatile("synco" ::: "memory")
40 # define rmb() asm volatile("" ::: "memory")
42 #define cpu_relax() asm volatile("" ::: "memory")
43 #define CPUINFO_PROC "cpu type"
47 #define rmb() asm volatile("" ::: "memory")
48 #define cpu_relax() asm volatile("" ::: "memory");
49 #define CPUINFO_PROC "cpu"
53 #define rmb() asm volatile("":::"memory")
54 #define cpu_relax() asm volatile("":::"memory")
55 #define CPUINFO_PROC "cpu"
59 #define rmb() asm volatile("mb" ::: "memory")
60 #define cpu_relax() asm volatile("" ::: "memory")
61 #define CPUINFO_PROC "cpu model"
65 #define rmb() asm volatile ("mf" ::: "memory")
66 #define cpu_relax() asm volatile ("hint @pause" ::: "memory")
67 #define CPUINFO_PROC "model name"
72 * Use the __kuser_memory_barrier helper in the CPU helper page. See
73 * arch/arm/kernel/entry-armv.S in the kernel source for details.
75 #define rmb() ((void(*)(void))0xffff0fa0)()
76 #define cpu_relax() asm volatile("":::"memory")
77 #define CPUINFO_PROC "Processor"
81 #define rmb() asm volatile("dmb ld" ::: "memory")
82 #define cpu_relax() asm volatile("yield" ::: "memory")
86 #define rmb() asm volatile( \
93 #define cpu_relax() asm volatile("" ::: "memory")
94 #define CPUINFO_PROC "cpu model"
98 #define rmb() asm volatile("" ::: "memory")
99 #define cpu_relax() rmb()
100 #define CPUINFO_PROC "Processor"
104 #define rmb() asm volatile("" ::: "memory")
105 #define cpu_relax() asm volatile("" ::: "memory")
106 #define CPUINFO_PROC "CPU"
111 #include <sys/types.h>
112 #include <sys/syscall.h>
114 #include <linux/perf_event.h>
115 #include "util/types.h"
119 * prctl(PR_TASK_PERF_EVENTS_DISABLE) will (cheaply) disable all
120 * counters in the current task.
122 #define PR_TASK_PERF_EVENTS_DISABLE 31
123 #define PR_TASK_PERF_EVENTS_ENABLE 32
126 # define NSEC_PER_SEC 1000000000ULL
129 static inline unsigned long long rdclock(void)
133 clock_gettime(CLOCK_MONOTONIC
, &ts
);
134 return ts
.tv_sec
* 1000000000ULL + ts
.tv_nsec
;
138 * Pick up some kernel type conventions:
143 #define unlikely(x) __builtin_expect(!!(x), 0)
144 #define min(x, y) ({ \
145 typeof(x) _min1 = (x); \
146 typeof(y) _min2 = (y); \
147 (void) (&_min1 == &_min2); \
148 _min1 < _min2 ? _min1 : _min2; })
150 extern bool test_attr__enabled
;
151 void test_attr__init(void);
152 void test_attr__open(struct perf_event_attr
*attr
, pid_t pid
, int cpu
,
153 int fd
, int group_fd
, unsigned long flags
);
156 sys_perf_event_open(struct perf_event_attr
*attr
,
157 pid_t pid
, int cpu
, int group_fd
,
162 fd
= syscall(__NR_perf_event_open
, attr
, pid
, cpu
,
165 if (unlikely(test_attr__enabled
))
166 test_attr__open(attr
, pid
, cpu
, fd
, group_fd
, flags
);
171 #define MAX_COUNTERS 256
172 #define MAX_NR_CPUS 256
174 struct ip_callchain
{
179 struct branch_flags
{
185 struct branch_entry
{
188 struct branch_flags flags
;
191 struct branch_stack
{
193 struct branch_entry entries
[0];
196 extern const char *input_name
;
197 extern bool perf_host
, perf_guest
;
198 extern const char perf_version_string
[];
200 void pthread__unblock_sigwinch(void);
202 #include "util/target.h"
204 enum perf_call_graph_mode
{
210 struct perf_record_opts
{
211 struct perf_target target
;
225 unsigned int mmap_pages
;
226 unsigned int user_freq
;
228 u64 default_interval
;