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> |
Arnaldo Carvalho de Melo | 14f0652 | 2016-07-18 17:40:49 -0300 | [diff] [blame] | 8 | #include <linux/compiler.h> |
Arnaldo Carvalho de Melo | 91854f9 | 2019-08-29 14:59:50 -0300 | [diff] [blame] | 9 | |
| 10 | struct perf_event_attr; |
| 11 | |
| 12 | extern bool test_attr__enabled; |
| 13 | void test_attr__ready(void); |
| 14 | void test_attr__init(void); |
| 15 | void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, |
| 16 | int fd, int group_fd, unsigned long flags); |
| 17 | |
Björn Töpel | 6bd7cf6 | 2019-10-01 13:33:06 +0200 | [diff] [blame] | 18 | #ifndef HAVE_ATTR_TEST |
| 19 | #define HAVE_ATTR_TEST 1 |
| 20 | #endif |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 21 | |
Jiri Olsa | 82baa0e | 2014-05-05 12:58:31 +0200 | [diff] [blame] | 22 | static inline int |
| 23 | sys_perf_event_open(struct perf_event_attr *attr, |
| 24 | pid_t pid, int cpu, int group_fd, |
| 25 | unsigned long flags) |
| 26 | { |
| 27 | int fd; |
| 28 | |
| 29 | fd = syscall(__NR_perf_event_open, attr, pid, cpu, |
| 30 | group_fd, flags); |
| 31 | |
Björn Töpel | 6bd7cf6 | 2019-10-01 13:33:06 +0200 | [diff] [blame] | 32 | #if HAVE_ATTR_TEST |
Jiri Olsa | 82baa0e | 2014-05-05 12:58:31 +0200 | [diff] [blame] | 33 | if (unlikely(test_attr__enabled)) |
| 34 | test_attr__open(attr, pid, cpu, fd, group_fd, flags); |
| 35 | #endif |
| 36 | return fd; |
| 37 | } |
| 38 | |
Jiri Olsa | 43599d1 | 2014-05-05 12:53:20 +0200 | [diff] [blame] | 39 | #endif /* _PERF_SYS_H */ |