Linux Audio

Check our new training course

Loading...
v6.2
 1// SPDX-License-Identifier: GPL-2.0-only
 2#ifndef METRICGROUP_H
 3#define METRICGROUP_H 1
 4
 5#include <linux/list.h>
 6#include <linux/rbtree.h>
 7#include <stdbool.h>
 8#include "pmu-events/pmu-events.h"
 9
10struct evlist;
11struct evsel;
12struct option;
13struct print_callbacks;
14struct rblist;
15struct cgroup;
16
17/**
18 * A node in a rblist keyed by the evsel. The global rblist of metric events
19 * generally exists in perf_stat_config. The evsel is looked up in the rblist
20 * yielding a list of metric_expr.
21 */
22struct metric_event {
23	struct rb_node nd;
24	struct evsel *evsel;
 
25	struct list_head head; /* list of metric_expr */
26};
27
28/**
29 * A metric referenced by a metric_expr. When parsing a metric expression IDs
30 * will be looked up, matching either a value (from metric_events) or a
31 * metric_ref. A metric_ref will then be parsed recursively. The metric_refs and
32 * metric_events need to be known before parsing so that their values may be
33 * placed in the parse context for lookup.
34 */
35struct metric_ref {
36	const char *metric_name;
37	const char *metric_expr;
38};
39
40/**
41 * One in a list of metric_expr associated with an evsel. The data is used to
42 * generate a metric value during stat output.
43 */
44struct metric_expr {
45	struct list_head nd;
46	/** The expression to parse, for example, "instructions/cycles". */
47	const char *metric_expr;
48	/** The name of the meric such as "IPC". */
49	const char *metric_name;
 
50	/**
51	 * The "ScaleUnit" that scales and adds a unit to the metric during
52	 * output. For example, "6.4e-05MiB" means to scale the resulting metric
53	 * by 6.4e-05 (typically converting a unit like cache lines to something
54	 * more human intelligible) and then add "MiB" afterward when displayed.
55	 */
56	const char *metric_unit;
 
 
57	/** Null terminated array of events used by the metric. */
58	struct evsel **metric_events;
59	/** Null terminated array of referenced metrics. */
60	struct metric_ref *metric_refs;
61	/** A value substituted for '?' during parsing. */
62	int runtime;
63};
64
65struct metric_event *metricgroup__lookup(struct rblist *metric_events,
66					 struct evsel *evsel,
67					 bool create);
68int metricgroup__parse_groups(struct evlist *perf_evlist,
 
69			      const char *str,
70			      bool metric_no_group,
71			      bool metric_no_merge,
 
72			      const char *user_requested_cpu_list,
73			      bool system_wide,
 
74			      struct rblist *metric_events);
75int metricgroup__parse_groups_test(struct evlist *evlist,
76				   const struct pmu_events_table *table,
77				   const char *str,
78				   bool metric_no_group,
79				   bool metric_no_merge,
80				   struct rblist *metric_events);
81
82void metricgroup__print(const struct print_callbacks *print_cb, void *print_state);
83bool metricgroup__has_metric(const char *metric);
84int arch_get_runtimeparam(const struct pmu_event *pe __maybe_unused);
 
85void metricgroup__rblist_exit(struct rblist *metric_events);
86
87int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp,
88				    struct rblist *new_metric_events,
89				    struct rblist *old_metric_events);
90#endif
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-only
 2#ifndef METRICGROUP_H
 3#define METRICGROUP_H 1
 4
 5#include <linux/list.h>
 6#include <linux/rbtree.h>
 7#include <stdbool.h>
 8#include "pmu-events/pmu-events.h"
 9
10struct evlist;
11struct evsel;
12struct option;
13struct print_callbacks;
14struct rblist;
15struct cgroup;
16
17/**
18 * A node in a rblist keyed by the evsel. The global rblist of metric events
19 * generally exists in perf_stat_config. The evsel is looked up in the rblist
20 * yielding a list of metric_expr.
21 */
22struct metric_event {
23	struct rb_node nd;
24	struct evsel *evsel;
25	bool is_default; /* the metric evsel from the Default metricgroup */
26	struct list_head head; /* list of metric_expr */
27};
28
29/**
30 * A metric referenced by a metric_expr. When parsing a metric expression IDs
31 * will be looked up, matching either a value (from metric_events) or a
32 * metric_ref. A metric_ref will then be parsed recursively. The metric_refs and
33 * metric_events need to be known before parsing so that their values may be
34 * placed in the parse context for lookup.
35 */
36struct metric_ref {
37	const char *metric_name;
38	const char *metric_expr;
39};
40
41/**
42 * One in a list of metric_expr associated with an evsel. The data is used to
43 * generate a metric value during stat output.
44 */
45struct metric_expr {
46	struct list_head nd;
47	/** The expression to parse, for example, "instructions/cycles". */
48	const char *metric_expr;
49	/** The name of the meric such as "IPC". */
50	const char *metric_name;
51	const char *metric_threshold;
52	/**
53	 * The "ScaleUnit" that scales and adds a unit to the metric during
54	 * output. For example, "6.4e-05MiB" means to scale the resulting metric
55	 * by 6.4e-05 (typically converting a unit like cache lines to something
56	 * more human intelligible) and then add "MiB" afterward when displayed.
57	 */
58	const char *metric_unit;
59	/** Displayed metricgroup name of the Default metricgroup */
60	const char *default_metricgroup_name;
61	/** Null terminated array of events used by the metric. */
62	struct evsel **metric_events;
63	/** Null terminated array of referenced metrics. */
64	struct metric_ref *metric_refs;
65	/** A value substituted for '?' during parsing. */
66	int runtime;
67};
68
69struct metric_event *metricgroup__lookup(struct rblist *metric_events,
70					 struct evsel *evsel,
71					 bool create);
72int metricgroup__parse_groups(struct evlist *perf_evlist,
73			      const char *pmu,
74			      const char *str,
75			      bool metric_no_group,
76			      bool metric_no_merge,
77			      bool metric_no_threshold,
78			      const char *user_requested_cpu_list,
79			      bool system_wide,
80			      bool hardware_aware_grouping,
81			      struct rblist *metric_events);
82int metricgroup__parse_groups_test(struct evlist *evlist,
83				   const struct pmu_metrics_table *table,
84				   const char *str,
 
 
85				   struct rblist *metric_events);
86
87void metricgroup__print(const struct print_callbacks *print_cb, void *print_state);
88bool metricgroup__has_metric(const char *pmu, const char *metric);
89unsigned int metricgroups__topdown_max_level(void);
90int arch_get_runtimeparam(const struct pmu_metric *pm);
91void metricgroup__rblist_exit(struct rblist *metric_events);
92
93int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp,
94				    struct rblist *new_metric_events,
95				    struct rblist *old_metric_events);
96#endif