1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef PMU_EVENTS_H 3 #define PMU_EVENTS_H 4 5 #include <stdbool.h> 6 7 struct perf_pmu; 8 9 enum aggr_mode_class { 10 PerChip = 1, 11 PerCore 12 }; 13 14 /** 15 * enum metric_event_groups - How events within a pmu_metric should be grouped. 16 */ 17 enum metric_event_groups { 18 /** 19 * @MetricGroupEvents: Default, group events within the metric. 20 */ 21 MetricGroupEvents = 0, 22 /** 23 * @MetricNoGroupEvents: Don't group events for the metric. 24 */ 25 MetricNoGroupEvents = 1, 26 /** 27 * @MetricNoGroupEventsNmi: Don't group events for the metric if the NMI 28 * watchdog is enabled. 29 */ 30 MetricNoGroupEventsNmi = 2, 31 /** 32 * @MetricNoGroupEventsSmt: Don't group events for the metric if SMT is 33 * enabled. 34 */ 35 MetricNoGroupEventsSmt = 3, 36 }; 37 /* 38 * Describe each PMU event. Each CPU has a table of PMU events. 39 */ 40 struct pmu_event { 41 const char *name; 42 const char *compat; 43 const char *event; 44 const char *desc; 45 const char *topic; 46 const char *long_desc; 47 const char *pmu; 48 const char *unit; 49 bool perpkg; 50 bool deprecated; 51 }; 52 53 struct pmu_metric { 54 const char *metric_name; 55 const char *metric_group; 56 const char *metric_expr; 57 const char *metric_threshold; 58 const char *unit; 59 const char *compat; 60 const char *desc; 61 const char *long_desc; 62 enum aggr_mode_class aggr_mode; 63 enum metric_event_groups event_grouping; 64 }; 65 66 struct pmu_events_table; 67 struct pmu_metrics_table; 68 69 typedef int (*pmu_event_iter_fn)(const struct pmu_event *pe, 70 const struct pmu_events_table *table, 71 void *data); 72 73 typedef int (*pmu_metric_iter_fn)(const struct pmu_metric *pm, 74 const struct pmu_metrics_table *table, 75 void *data); 76 77 int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_event_iter_fn fn, 78 void *data); 79 int pmu_metrics_table_for_each_metric(const struct pmu_metrics_table *table, pmu_metric_iter_fn fn, 80 void *data); 81 82 const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu); 83 const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu); 84 const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid); 85 const struct pmu_metrics_table *find_core_metrics_table(const char *arch, const char *cpuid); 86 int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data); 87 int pmu_for_each_core_metric(pmu_metric_iter_fn fn, void *data); 88 89 const struct pmu_events_table *find_sys_events_table(const char *name); 90 const struct pmu_metrics_table *find_sys_metrics_table(const char *name); 91 int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data); 92 int pmu_for_each_sys_metric(pmu_metric_iter_fn fn, void *data); 93 94 #endif 95