pmu.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef __PMU_H
  2. #define __PMU_H
  3. #include <linux/bitmap.h>
  4. #include <linux/perf_event.h>
  5. #include <stdbool.h>
  6. #include "parse-events.h"
  7. enum {
  8. PERF_PMU_FORMAT_VALUE_CONFIG,
  9. PERF_PMU_FORMAT_VALUE_CONFIG1,
  10. PERF_PMU_FORMAT_VALUE_CONFIG2,
  11. };
  12. #define PERF_PMU_FORMAT_BITS 64
  13. struct perf_event_attr;
  14. struct perf_pmu {
  15. char *name;
  16. __u32 type;
  17. bool selectable;
  18. struct perf_event_attr *default_config;
  19. struct cpu_map *cpus;
  20. struct list_head format; /* HEAD struct perf_pmu_format -> list */
  21. struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
  22. struct list_head list; /* ELEM */
  23. };
  24. struct perf_pmu_info {
  25. const char *unit;
  26. double scale;
  27. bool per_pkg;
  28. bool snapshot;
  29. };
  30. #define UNIT_MAX_LEN 31 /* max length for event unit name */
  31. struct perf_pmu_alias {
  32. char *name;
  33. struct list_head terms; /* HEAD struct parse_events_term -> list */
  34. struct list_head list; /* ELEM */
  35. char unit[UNIT_MAX_LEN+1];
  36. double scale;
  37. bool per_pkg;
  38. bool snapshot;
  39. };
  40. struct perf_pmu *perf_pmu__find(const char *name);
  41. int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
  42. struct list_head *head_terms,
  43. struct parse_events_error *error);
  44. int perf_pmu__config_terms(struct list_head *formats,
  45. struct perf_event_attr *attr,
  46. struct list_head *head_terms,
  47. bool zero, struct parse_events_error *error);
  48. __u64 perf_pmu__format_bits(struct list_head *formats, const char *name);
  49. int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
  50. struct perf_pmu_info *info);
  51. struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
  52. struct list_head *head_terms);
  53. int perf_pmu_wrap(void);
  54. void perf_pmu_error(struct list_head *list, char *name, char const *msg);
  55. int perf_pmu__new_format(struct list_head *list, char *name,
  56. int config, unsigned long *bits);
  57. void perf_pmu__set_format(unsigned long *bits, long from, long to);
  58. int perf_pmu__format_parse(char *dir, struct list_head *head);
  59. struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
  60. void print_pmu_events(const char *event_glob, bool name_only);
  61. bool pmu_have_event(const char *pname, const char *name);
  62. int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
  63. ...) __attribute__((format(scanf, 3, 4)));
  64. int perf_pmu__test(void);
  65. struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
  66. #endif /* __PMU_H */