Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 2 | #ifndef _PERF_SYS_H |
| 3 | #define _PERF_SYS_H |
| 4 | |
Jiri Olsa | 82baa0e | 2014-05-05 12:58:31 +0200 | [diff] [blame] | 5 | #include <unistd.h> |
| 6 | #include <sys/types.h> |
| 7 | #include <sys/syscall.h> |
| 8 | #include <linux/types.h> |
Arnaldo Carvalho de Melo | 14f0652 | 2016-07-18 17:40:49 -0300 | [diff] [blame] | 9 | #include <linux/compiler.h> |
Jiri Olsa | 82baa0e | 2014-05-05 12:58:31 +0200 | [diff] [blame] | 10 | #include <linux/perf_event.h> |
Arnaldo Carvalho de Melo | 361c564 | 2015-04-30 12:33:22 -0300 | [diff] [blame] | 11 | #include <asm/barrier.h> |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 12 | |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 13 | #ifdef __powerpc__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 14 | #define CPUINFO_PROC {"cpu"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 15 | #endif |
| 16 | |
| 17 | #ifdef __s390__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 18 | #define CPUINFO_PROC {"vendor_id"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 19 | #endif |
| 20 | |
| 21 | #ifdef __sh__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 22 | #define CPUINFO_PROC {"cpu type"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 23 | #endif |
| 24 | |
| 25 | #ifdef __hppa__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 26 | #define CPUINFO_PROC {"cpu"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 27 | #endif |
| 28 | |
| 29 | #ifdef __sparc__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 30 | #define CPUINFO_PROC {"cpu"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 31 | #endif |
| 32 | |
| 33 | #ifdef __alpha__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 34 | #define CPUINFO_PROC {"cpu model"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 35 | #endif |
| 36 | |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 37 | #ifdef __arm__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 38 | #define CPUINFO_PROC {"model name", "Processor"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 39 | #endif |
| 40 | |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 41 | #ifdef __mips__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 42 | #define CPUINFO_PROC {"cpu model"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 43 | #endif |
| 44 | |
| 45 | #ifdef __arc__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 46 | #define CPUINFO_PROC {"Processor"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 47 | #endif |
| 48 | |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 49 | #ifdef __xtensa__ |
Wang Nan | 493c303 | 2014-10-24 09:45:26 +0800 | [diff] [blame] | 50 | #define CPUINFO_PROC {"core ID"} |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 51 | #endif |
| 52 | |
Arnaldo Carvalho de Melo | 9a57eaf | 2017-08-17 16:58:21 -0300 | [diff] [blame] | 53 | #ifndef CPUINFO_PROC |
| 54 | #define CPUINFO_PROC { "model name", } |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 55 | #endif |
| 56 | |
Jiri Olsa | 82baa0e | 2014-05-05 12:58:31 +0200 | [diff] [blame] | 57 | static inline int |
| 58 | sys_perf_event_open(struct perf_event_attr *attr, |
| 59 | pid_t pid, int cpu, int group_fd, |
| 60 | unsigned long flags) |
| 61 | { |
| 62 | int fd; |
| 63 | |
| 64 | fd = syscall(__NR_perf_event_open, attr, pid, cpu, |
| 65 | group_fd, flags); |
| 66 | |
| 67 | #ifdef HAVE_ATTR_TEST |
| 68 | if (unlikely(test_attr__enabled)) |
| 69 | test_attr__open(attr, pid, cpu, fd, group_fd, flags); |
| 70 | #endif |
| 71 | return fd; |
| 72 | } |
| 73 | |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 74 | #endif /* _PERF_SYS_H */ |