6 void get_term_dimensions(struct winsize *ws);
9 #include "../../arch/x86/include/asm/unistd.h"
10 #define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
11 #define cpu_relax() asm volatile("rep; nop" ::: "memory");
12 #define CPUINFO_PROC "model name"
13 #ifndef __NR_perf_event_open
14 # define __NR_perf_event_open 336
18 #if defined(__x86_64__)
19 #include "../../arch/x86/include/asm/unistd.h"
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 #include "../../arch/powerpc/include/asm/unistd.h"
30 #define rmb() asm volatile ("sync" ::: "memory")
31 #define cpu_relax() asm volatile ("" ::: "memory");
32 #define CPUINFO_PROC "cpu"
36 #include "../../arch/s390/include/asm/unistd.h"
37 #define rmb() asm volatile("bcr 15,0" ::: "memory")
38 #define cpu_relax() asm volatile("" ::: "memory");
42 #include "../../arch/sh/include/asm/unistd.h"
43 #if defined(__SH4A__) || defined(__SH5__)
44 # define rmb() asm volatile("synco" ::: "memory")
46 # define rmb() asm volatile("" ::: "memory")
48 #define cpu_relax() asm volatile("" ::: "memory")
49 #define CPUINFO_PROC "cpu type"
53 #include "../../arch/parisc/include/asm/unistd.h"
54 #define rmb() asm volatile("" ::: "memory")
55 #define cpu_relax() asm volatile("" ::: "memory");
56 #define CPUINFO_PROC "cpu"
60 #include "../../arch/sparc/include/uapi/asm/unistd.h"
61 #define rmb() asm volatile("":::"memory")
62 #define cpu_relax() asm volatile("":::"memory")
63 #define CPUINFO_PROC "cpu"
67 #include "../../arch/alpha/include/asm/unistd.h"
68 #define rmb() asm volatile("mb" ::: "memory")
69 #define cpu_relax() asm volatile("" ::: "memory")
70 #define CPUINFO_PROC "cpu model"
74 #include "../../arch/ia64/include/asm/unistd.h"
75 #define rmb() asm volatile ("mf" ::: "memory")
76 #define cpu_relax() asm volatile ("hint @pause" ::: "memory")
77 #define CPUINFO_PROC "model name"
81 #include "../../arch/arm/include/asm/unistd.h"
83 * Use the __kuser_memory_barrier helper in the CPU helper page. See
84 * arch/arm/kernel/entry-armv.S in the kernel source for details.
86 #define rmb() ((void(*)(void))0xffff0fa0)()
87 #define cpu_relax() asm volatile("":::"memory")
88 #define CPUINFO_PROC "Processor"
92 #include "../../arch/arm64/include/asm/unistd.h"
93 #define rmb() asm volatile("dmb ld" ::: "memory")
94 #define cpu_relax() asm volatile("yield" ::: "memory")
98 #include "../../arch/mips/include/asm/unistd.h"
99 #define rmb() asm volatile( \
106 #define cpu_relax() asm volatile("" ::: "memory")
107 #define CPUINFO_PROC "cpu model"
112 #include <sys/types.h>
113 #include <sys/syscall.h>
115 #include "../../include/uapi/linux/perf_event.h"
116 #include "util/types.h"
125 static inline unsigned int perf_mmap__read_head(struct perf_mmap *mm)
127 struct perf_event_mmap_page *pc = mm->base;
128 int head = pc->data_head;
133 static inline void perf_mmap__write_tail(struct perf_mmap *md,
136 struct perf_event_mmap_page *pc = md->base;
139 * ensure all reads are done before we write the tail out.
142 pc->data_tail = tail;
146 * prctl(PR_TASK_PERF_EVENTS_DISABLE) will (cheaply) disable all
147 * counters in the current task.
149 #define PR_TASK_PERF_EVENTS_DISABLE 31
150 #define PR_TASK_PERF_EVENTS_ENABLE 32
153 # define NSEC_PER_SEC 1000000000ULL
156 static inline unsigned long long rdclock(void)
160 clock_gettime(CLOCK_MONOTONIC, &ts);
161 return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
165 * Pick up some kernel type conventions:
170 #define unlikely(x) __builtin_expect(!!(x), 0)
171 #define min(x, y) ({ \
172 typeof(x) _min1 = (x); \
173 typeof(y) _min2 = (y); \
174 (void) (&_min1 == &_min2); \
175 _min1 < _min2 ? _min1 : _min2; })
178 sys_perf_event_open(struct perf_event_attr *attr,
179 pid_t pid, int cpu, int group_fd,
182 return syscall(__NR_perf_event_open, attr, pid, cpu,
186 #define MAX_COUNTERS 256
187 #define MAX_NR_CPUS 256
189 struct ip_callchain {
194 struct branch_flags {
200 struct branch_entry {
203 struct branch_flags flags;
206 struct branch_stack {
208 struct branch_entry entries[0];
211 extern bool perf_host, perf_guest;
212 extern const char perf_version_string[];
214 void pthread__unblock_sigwinch(void);
216 #include "util/target.h"
218 enum perf_call_graph_mode {
224 struct perf_record_opts {
225 struct perf_target target;
236 bool sample_id_all_missing;
237 bool exclude_guest_missing;
240 unsigned int mmap_pages;
241 unsigned int user_freq;
243 u64 default_interval;