perf-sys.h 856 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _PERF_SYS_H
  3. #define _PERF_SYS_H
  4. #include <unistd.h>
  5. #include <sys/types.h>
  6. #include <sys/syscall.h>
  7. #include <linux/compiler.h>
  8. struct perf_event_attr;
  9. extern bool test_attr__enabled;
  10. void test_attr__ready(void);
  11. void test_attr__init(void);
  12. void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
  13. int fd, int group_fd, unsigned long flags);
  14. #ifndef HAVE_ATTR_TEST
  15. #define HAVE_ATTR_TEST 1
  16. #endif
  17. static inline int
  18. sys_perf_event_open(struct perf_event_attr *attr,
  19. pid_t pid, int cpu, int group_fd,
  20. unsigned long flags)
  21. {
  22. int fd;
  23. fd = syscall(__NR_perf_event_open, attr, pid, cpu,
  24. group_fd, flags);
  25. #if HAVE_ATTR_TEST
  26. if (unlikely(test_attr__enabled))
  27. test_attr__open(attr, pid, cpu, fd, group_fd, flags);
  28. #endif
  29. return fd;
  30. }
  31. #endif /* _PERF_SYS_H */