perf-sys.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 __metag__
  39. #define CPUINFO_PROC {"CPU"}
  40. #endif
  41. #ifdef __xtensa__
  42. #define CPUINFO_PROC {"core ID"}
  43. #endif
  44. #ifndef CPUINFO_PROC
  45. #define CPUINFO_PROC { "model name", }
  46. #endif
  47. static inline int
  48. sys_perf_event_open(struct perf_event_attr *attr,
  49. pid_t pid, int cpu, int group_fd,
  50. unsigned long flags)
  51. {
  52. int fd;
  53. fd = syscall(__NR_perf_event_open, attr, pid, cpu,
  54. group_fd, flags);
  55. #ifdef HAVE_ATTR_TEST
  56. if (unlikely(test_attr__enabled))
  57. test_attr__open(attr, pid, cpu, fd, group_fd, flags);
  58. #endif
  59. return fd;
  60. }
  61. #endif /* _PERF_SYS_H */