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 #include "../../arch/powerpc/include/uapi/asm/unistd.h"
30 #define rmb() asm volatile ("sync" ::: "memory")
31 #define cpu_relax() asm volatile ("" ::: "memory");
32 #define CPUINFO_PROC "cpu"
36 #define rmb() asm volatile("bcr 15,0" ::: "memory")
37 #define cpu_relax() asm volatile("" ::: "memory");
41 #if defined(__SH4A__) || defined(__SH5__)
42 # define rmb() asm volatile("synco" ::: "memory")
44 # define rmb() asm volatile("" ::: "memory")
46 #define cpu_relax() asm volatile("" ::: "memory")
47 #define CPUINFO_PROC "cpu type"
51 #define rmb() asm volatile("" ::: "memory")
52 #define cpu_relax() asm volatile("" ::: "memory");
53 #define CPUINFO_PROC "cpu"
57 #define rmb() asm volatile("":::"memory")
58 #define cpu_relax() asm volatile("":::"memory")
59 #define CPUINFO_PROC "cpu"
63 #define rmb() asm volatile("mb" ::: "memory")
64 #define cpu_relax() asm volatile("" ::: "memory")
65 #define CPUINFO_PROC "cpu model"
69 #define rmb() asm volatile ("mf" ::: "memory")
70 #define cpu_relax() asm volatile ("hint @pause" ::: "memory")
71 #define CPUINFO_PROC "model name"
76 * Use the __kuser_memory_barrier helper in the CPU helper page. See
77 * arch/arm/kernel/entry-armv.S in the kernel source for details.
79 #define rmb() ((void(*)(void))0xffff0fa0)()
80 #define cpu_relax() asm volatile("":::"memory")
81 #define CPUINFO_PROC "Processor"
85 #define rmb() asm volatile("dmb ld" ::: "memory")
86 #define cpu_relax() asm volatile("yield" ::: "memory")
90 #define rmb() asm volatile( \
97 #define cpu_relax() asm volatile("" ::: "memory")
98 #define CPUINFO_PROC "cpu model"
103 #include <sys/types.h>
104 #include <sys/syscall.h>
106 #include <linux/perf_event.h>
107 #include "util/types.h"
116 static inline unsigned int perf_mmap__read_head(struct perf_mmap *mm)
118 struct perf_event_mmap_page *pc = mm->base;
119 int head = pc->data_head;
124 static inline void perf_mmap__write_tail(struct perf_mmap *md,
127 struct perf_event_mmap_page *pc = md->base;
130 * ensure all reads are done before we write the tail out.
133 pc->data_tail = tail;
137 * prctl(PR_TASK_PERF_EVENTS_DISABLE) will (cheaply) disable all
138 * counters in the current task.
140 #define PR_TASK_PERF_EVENTS_DISABLE 31
141 #define PR_TASK_PERF_EVENTS_ENABLE 32
144 # define NSEC_PER_SEC 1000000000ULL
147 static inline unsigned long long rdclock(void)
151 clock_gettime(CLOCK_MONOTONIC, &ts);
152 return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
156 * Pick up some kernel type conventions:
161 #define unlikely(x) __builtin_expect(!!(x), 0)
162 #define min(x, y) ({ \
163 typeof(x) _min1 = (x); \
164 typeof(y) _min2 = (y); \
165 (void) (&_min1 == &_min2); \
166 _min1 < _min2 ? _min1 : _min2; })
168 extern bool test_attr__enabled;
169 void test_attr__init(void);
170 void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
171 int fd, int group_fd, unsigned long flags);
174 sys_perf_event_open(struct perf_event_attr *attr,
175 pid_t pid, int cpu, int group_fd,
180 fd = syscall(__NR_perf_event_open, attr, pid, cpu,
183 if (unlikely(test_attr__enabled))
184 test_attr__open(attr, pid, cpu, fd, group_fd, flags);
189 #define MAX_COUNTERS 256
190 #define MAX_NR_CPUS 256
192 struct ip_callchain {
197 struct branch_flags {
203 struct branch_entry {
206 struct branch_flags flags;
209 struct branch_stack {
211 struct branch_entry entries[0];
214 extern const char *input_name;
215 extern bool perf_host, perf_guest;
216 extern const char perf_version_string[];
218 void pthread__unblock_sigwinch(void);
220 #include "util/target.h"
222 enum perf_call_graph_mode {
228 struct perf_record_opts {
229 struct perf_target target;
240 bool sample_id_all_missing;
241 bool exclude_guest_missing;
244 unsigned int mmap_pages;
245 unsigned int user_freq;
247 u64 default_interval;