Linux Audio

Check our new training course

Linux BSP upgrade and security maintenance

Need help to get security updates for your Linux BSP?
Loading...
v6.2
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef PMU_EVENTS_H
 3#define PMU_EVENTS_H
 4
 
 
 
 5struct perf_pmu;
 6
 7enum aggr_mode_class {
 8	PerChip = 1,
 9	PerCore
10};
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12/*
13 * Describe each PMU event. Each CPU has a table of PMU events.
14 */
15struct pmu_event {
16	const char *name;
17	const char *compat;
18	const char *event;
19	const char *desc;
20	const char *topic;
21	const char *long_desc;
22	const char *pmu;
23	const char *unit;
24	const char *perpkg;
25	const char *aggr_mode;
26	const char *metric_expr;
 
 
 
27	const char *metric_name;
28	const char *metric_group;
29	const char *deprecated;
30	const char *metric_constraint;
 
 
 
 
 
 
 
 
31};
32
33struct pmu_events_table;
 
 
 
34
35typedef int (*pmu_event_iter_fn)(const struct pmu_event *pe,
36				 const struct pmu_events_table *table,
37				 void *data);
38
39int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_event_iter_fn fn,
 
 
 
 
 
 
40				    void *data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
42const struct pmu_events_table *perf_pmu__find_table(struct perf_pmu *pmu);
 
 
 
 
43const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid);
 
44int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data);
 
45
46const struct pmu_events_table *find_sys_events_table(const char *name);
 
47int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data);
 
 
 
48
49#endif
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef PMU_EVENTS_H
  3#define PMU_EVENTS_H
  4
  5#include <stdbool.h>
  6#include <stddef.h>
  7
  8struct perf_pmu;
  9
 10enum aggr_mode_class {
 11	PerChip = 1,
 12	PerCore
 13};
 14
 15/**
 16 * enum metric_event_groups - How events within a pmu_metric should be grouped.
 17 */
 18enum metric_event_groups {
 19	/**
 20	 * @MetricGroupEvents: Default, group events within the metric.
 21	 */
 22	MetricGroupEvents = 0,
 23	/**
 24	 * @MetricNoGroupEvents: Don't group events for the metric.
 25	 */
 26	MetricNoGroupEvents = 1,
 27	/**
 28	 * @MetricNoGroupEventsNmi: Don't group events for the metric if the NMI
 29	 *                          watchdog is enabled.
 30	 */
 31	MetricNoGroupEventsNmi = 2,
 32	/**
 33	 * @MetricNoGroupEventsSmt: Don't group events for the metric if SMT is
 34	 *                          enabled.
 35	 */
 36	MetricNoGroupEventsSmt = 3,
 37};
 38/*
 39 * Describe each PMU event. Each CPU has a table of PMU events.
 40 */
 41struct pmu_event {
 42	const char *name;
 43	const char *compat;
 44	const char *event;
 45	const char *desc;
 46	const char *topic;
 47	const char *long_desc;
 48	const char *pmu;
 49	const char *unit;
 50	bool perpkg;
 51	bool deprecated;
 52};
 53
 54struct pmu_metric {
 55	const char *pmu;
 56	const char *metric_name;
 57	const char *metric_group;
 58	const char *metric_expr;
 59	const char *metric_threshold;
 60	const char *unit;
 61	const char *compat;
 62	const char *desc;
 63	const char *long_desc;
 64	const char *metricgroup_no_group;
 65	const char *default_metricgroup_name;
 66	enum aggr_mode_class aggr_mode;
 67	enum metric_event_groups event_grouping;
 68};
 69
 70struct pmu_events_table;
 71struct pmu_metrics_table;
 72
 73#define PMU_EVENTS__NOT_FOUND -1000
 74
 75typedef int (*pmu_event_iter_fn)(const struct pmu_event *pe,
 76				 const struct pmu_events_table *table,
 77				 void *data);
 78
 79typedef int (*pmu_metric_iter_fn)(const struct pmu_metric *pm,
 80				  const struct pmu_metrics_table *table,
 81				  void *data);
 82
 83int pmu_events_table__for_each_event(const struct pmu_events_table *table,
 84				    struct perf_pmu *pmu,
 85				    pmu_event_iter_fn fn,
 86				    void *data);
 87/*
 88 * Search for table and entry matching with pmu__name_match. Each matching event
 89 * has fn called on it. 0 implies to success/continue the search while non-zero
 90 * means to terminate. The special value PMU_EVENTS__NOT_FOUND is used to
 91 * indicate no event was found in one of the tables which doesn't terminate the
 92 * search of all tables.
 93 */
 94int pmu_events_table__find_event(const struct pmu_events_table *table,
 95                                 struct perf_pmu *pmu,
 96                                 const char *name,
 97                                 pmu_event_iter_fn fn,
 98				 void *data);
 99size_t pmu_events_table__num_events(const struct pmu_events_table *table,
100				    struct perf_pmu *pmu);
101
102int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table, pmu_metric_iter_fn fn,
103				     void *data);
104
105const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu);
106const struct pmu_metrics_table *pmu_metrics_table__find(void);
107const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid);
108const struct pmu_metrics_table *find_core_metrics_table(const char *arch, const char *cpuid);
109int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data);
110int pmu_for_each_core_metric(pmu_metric_iter_fn fn, void *data);
111
112const struct pmu_events_table *find_sys_events_table(const char *name);
113const struct pmu_metrics_table *find_sys_metrics_table(const char *name);
114int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data);
115int pmu_for_each_sys_metric(pmu_metric_iter_fn fn, void *data);
116
117const char *describe_metricgroup(const char *group);
118
119#endif