pmu.h 2.5 KB

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