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 const char *metricgroup_no_group; 63 enum aggr_mode_class aggr_mode; 64 enum metric_event_groups event_grouping; 65 }; 66 67 struct pmu_events_table; 68 struct pmu_metrics_table; 69 70 typedef int (*pmu_event_iter_fn)(const struct pmu_event *pe, 71 const struct pmu_events_table *table, 72 void *data); 73 74 typedef int (*pmu_metric_iter_fn)(const struct pmu_metric *pm, 75 const struct pmu_metrics_table *table, 76 void *data); 77 78 int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_event_iter_fn fn, 79 void *data); 80 int pmu_metrics_table_for_each_metric(const struct pmu_metrics_table *table, pmu_metric_iter_fn fn, 81 void *data); 82 83 const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu); 84 const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu); 85 const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid); 86 const struct pmu_metrics_table *find_core_metrics_table(const char *arch, const char *cpuid); 87 int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data); 88 int pmu_for_each_core_metric(pmu_metric_iter_fn fn, void *data); 89 90 const struct pmu_events_table *find_sys_events_table(const char *name); 91 const struct pmu_metrics_table *find_sys_metrics_table(const char *name); 92 int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data); 93 int pmu_for_each_sys_metric(pmu_metric_iter_fn fn, void *data); 94 95 #endif 96