• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _PERF_SYS_H
2 #define _PERF_SYS_H
3 
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/syscall.h>
7 #include <linux/types.h>
8 #include <linux/compiler.h>
9 #include <linux/perf_event.h>
10 #include <asm/barrier.h>
11 
12 #if defined(__i386__)
13 #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
14 #define CPUINFO_PROC	{"model name"}
15 #endif
16 
17 #if defined(__x86_64__)
18 #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
19 #define CPUINFO_PROC	{"model name"}
20 #endif
21 
22 #ifdef __powerpc__
23 #define CPUINFO_PROC	{"cpu"}
24 #endif
25 
26 #ifdef __s390__
27 #define CPUINFO_PROC	{"vendor_id"}
28 #endif
29 
30 #ifdef __sh__
31 #define CPUINFO_PROC	{"cpu type"}
32 #endif
33 
34 #ifdef __hppa__
35 #define CPUINFO_PROC	{"cpu"}
36 #endif
37 
38 #ifdef __sparc__
39 #define CPUINFO_PROC	{"cpu"}
40 #endif
41 
42 #ifdef __alpha__
43 #define CPUINFO_PROC	{"cpu model"}
44 #endif
45 
46 #ifdef __ia64__
47 #define cpu_relax()	asm volatile ("hint @pause" ::: "memory")
48 #define CPUINFO_PROC	{"model name"}
49 #endif
50 
51 #ifdef __arm__
52 #define CPUINFO_PROC	{"model name", "Processor"}
53 #endif
54 
55 #ifdef __aarch64__
56 #define cpu_relax()	asm volatile("yield" ::: "memory")
57 #endif
58 
59 #ifdef __mips__
60 #define CPUINFO_PROC	{"cpu model"}
61 #endif
62 
63 #ifdef __arc__
64 #define CPUINFO_PROC	{"Processor"}
65 #endif
66 
67 #ifdef __metag__
68 #define CPUINFO_PROC	{"CPU"}
69 #endif
70 
71 #ifdef __xtensa__
72 #define CPUINFO_PROC	{"core ID"}
73 #endif
74 
75 #ifdef __tile__
76 #define cpu_relax()	asm volatile ("mfspr zero, PASS" ::: "memory")
77 #define CPUINFO_PROC    {"model name"}
78 #endif
79 
80 #ifndef cpu_relax
81 #define cpu_relax() barrier()
82 #endif
83 
84 static inline int
sys_perf_event_open(struct perf_event_attr * attr,pid_t pid,int cpu,int group_fd,unsigned long flags)85 sys_perf_event_open(struct perf_event_attr *attr,
86 		      pid_t pid, int cpu, int group_fd,
87 		      unsigned long flags)
88 {
89 	int fd;
90 
91 	fd = syscall(__NR_perf_event_open, attr, pid, cpu,
92 		     group_fd, flags);
93 
94 #ifdef HAVE_ATTR_TEST
95 	if (unlikely(test_attr__enabled))
96 		test_attr__open(attr, pid, cpu, fd, group_fd, flags);
97 #endif
98 	return fd;
99 }
100 
101 #endif /* _PERF_SYS_H */
102