6 void get_term_dimensions(struct winsize
*ws
);
8 #include <asm/unistd.h>
11 #define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
12 #define cpu_relax() asm volatile("rep; nop" ::: "memory");
13 #define CPUINFO_PROC "model name"
14 #ifndef __NR_perf_event_open
15 # define __NR_perf_event_open 336
19 #if defined(__x86_64__)
20 #define rmb() asm volatile("lfence" ::: "memory")
21 #define cpu_relax() asm volatile("rep; nop" ::: "memory");
22 #define CPUINFO_PROC "model name"
23 #ifndef __NR_perf_event_open
24 # define __NR_perf_event_open 298
29 #define rmb() asm volatile ("sync" ::: "memory")
30 #define cpu_relax() asm volatile ("" ::: "memory");
31 #define CPUINFO_PROC "cpu"
35 #define rmb() asm volatile("bcr 15,0" ::: "memory")
36 #define cpu_relax() asm volatile("" ::: "memory");
40 #if defined(__SH4A__) || defined(__SH5__)
41 # define rmb() asm volatile("synco" ::: "memory")
43 # define rmb() asm volatile("" ::: "memory")
45 #define cpu_relax() asm volatile("" ::: "memory")
46 #define CPUINFO_PROC "cpu type"
50 #define rmb() asm volatile("" ::: "memory")
51 #define cpu_relax() asm volatile("" ::: "memory");
52 #define CPUINFO_PROC "cpu"
56 #define rmb() asm volatile("":::"memory")
57 #define cpu_relax() asm volatile("":::"memory")
58 #define CPUINFO_PROC "cpu"
62 #define rmb() asm volatile("mb" ::: "memory")
63 #define cpu_relax() asm volatile("" ::: "memory")
64 #define CPUINFO_PROC "cpu model"
68 #define rmb() asm volatile ("mf" ::: "memory")
69 #define cpu_relax() asm volatile ("hint @pause" ::: "memory")
70 #define CPUINFO_PROC "model name"
75 * Use the __kuser_memory_barrier helper in the CPU helper page. See
76 * arch/arm/kernel/entry-armv.S in the kernel source for details.
78 #define rmb() ((void(*)(void))0xffff0fa0)()
79 #define cpu_relax() asm volatile("":::"memory")
80 #define CPUINFO_PROC "Processor"
84 #define rmb() asm volatile("dmb ld" ::: "memory")
85 #define cpu_relax() asm volatile("yield" ::: "memory")
89 #define rmb() asm volatile( \
96 #define cpu_relax() asm volatile("" ::: "memory")
97 #define CPUINFO_PROC "cpu model"
102 #include <sys/types.h>
103 #include <sys/syscall.h>
105 #include <linux/perf_event.h>
106 #include "util/types.h"
115 static inline unsigned int perf_mmap__read_head(struct perf_mmap
*mm
)
117 struct perf_event_mmap_page
*pc
= mm
->base
;
118 int head
= pc
->data_head
;
123 static inline void perf_mmap__write_tail(struct perf_mmap
*md
,
126 struct perf_event_mmap_page
*pc
= md
->base
;
129 * ensure all reads are done before we write the tail out.
132 pc
->data_tail
= tail
;
136 * prctl(PR_TASK_PERF_EVENTS_DISABLE) will (cheaply) disable all
137 * counters in the current task.
139 #define PR_TASK_PERF_EVENTS_DISABLE 31
140 #define PR_TASK_PERF_EVENTS_ENABLE 32
143 # define NSEC_PER_SEC 1000000000ULL
146 static inline unsigned long long rdclock(void)
150 clock_gettime(CLOCK_MONOTONIC
, &ts
);
151 return ts
.tv_sec
* 1000000000ULL + ts
.tv_nsec
;
155 * Pick up some kernel type conventions:
160 #define unlikely(x) __builtin_expect(!!(x), 0)
161 #define min(x, y) ({ \
162 typeof(x) _min1 = (x); \
163 typeof(y) _min2 = (y); \
164 (void) (&_min1 == &_min2); \
165 _min1 < _min2 ? _min1 : _min2; })
168 sys_perf_event_open(struct perf_event_attr
*attr
,
169 pid_t pid
, int cpu
, int group_fd
,
172 return syscall(__NR_perf_event_open
, attr
, pid
, cpu
,
176 #define MAX_COUNTERS 256
177 #define MAX_NR_CPUS 256
179 struct ip_callchain
{
184 struct branch_flags
{
190 struct branch_entry
{
193 struct branch_flags flags
;
196 struct branch_stack
{
198 struct branch_entry entries
[0];
201 extern bool perf_host
, perf_guest
;
202 extern const char perf_version_string
[];
204 void pthread__unblock_sigwinch(void);
206 #include "util/target.h"
208 enum perf_call_graph_mode
{
214 struct perf_record_opts
{
215 struct perf_target target
;
226 bool sample_id_all_missing
;
227 bool exclude_guest_missing
;
230 unsigned int mmap_pages
;
231 unsigned int user_freq
;
233 u64 default_interval
;