perf-sys.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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/types.h>
  8. #include <linux/compiler.h>
  9. #include <linux/perf_event.h>
  10. #include <asm/barrier.h>
  11. #ifdef __powerpc__
  12. #define CPUINFO_PROC {"cpu"}
  13. #endif
  14. #ifdef __s390__
  15. #define CPUINFO_PROC {"vendor_id"}
  16. #endif
  17. #ifdef __sh__
  18. #define CPUINFO_PROC {"cpu type"}
  19. #endif
  20. #ifdef __hppa__
  21. #define CPUINFO_PROC {"cpu"}
  22. #endif
  23. #ifdef __sparc__
  24. #define CPUINFO_PROC {"cpu"}
  25. #endif
  26. #ifdef __alpha__
  27. #define CPUINFO_PROC {"cpu model"}
  28. #endif
  29. #ifdef __arm__
  30. #define CPUINFO_PROC {"model name", "Processor"}
  31. #endif
  32. #ifdef __mips__
  33. #define CPUINFO_PROC {"cpu model"}
  34. #endif
  35. #ifdef __arc__
  36. #define CPUINFO_PROC {"Processor"}
  37. #endif
  38. #ifdef __xtensa__
  39. #define CPUINFO_PROC {"core ID"}
  40. #endif
  41. #ifndef CPUINFO_PROC
  42. #define CPUINFO_PROC { "model name", }
  43. #endif
  44. static inline int
  45. sys_perf_event_open(struct perf_event_attr *attr,
  46. pid_t pid, int cpu, int group_fd,
  47. unsigned long flags)
  48. {
  49. int fd;
  50. fd = syscall(__NR_perf_event_open, attr, pid, cpu,
  51. group_fd, flags);
  52. #ifdef HAVE_ATTR_TEST
  53. if (unlikely(test_attr__enabled))
  54. test_attr__open(attr, pid, cpu, fd, group_fd, flags);
  55. #endif
  56. return fd;
  57. }
  58. #endif /* _PERF_SYS_H */