1 // SPDX-License-Identifier: GPL-2.0-only
3 #define METRICGROUP_H 1
5 #include <linux/list.h>
6 #include <linux/rbtree.h>
8 #include "pmu-events/pmu-events.h"
14 struct pmu_events_map;
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.
25 struct list_head head; /* list of metric_expr */
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.
36 const char *metric_name;
37 const char *metric_expr;
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.
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;
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.
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. */
65 struct metric_event *metricgroup__lookup(struct rblist *metric_events,
68 int metricgroup__parse_groups(const struct option *opt,
72 struct rblist *metric_events);
73 const struct pmu_event *metricgroup__find_metric(const char *metric,
74 const struct pmu_events_map *map);
75 int metricgroup__parse_groups_test(struct evlist *evlist,
76 const struct pmu_events_map *map,
80 struct rblist *metric_events);
82 void metricgroup__print(bool metrics, bool groups, char *filter,
83 bool raw, bool details, const char *pmu_name);
84 bool metricgroup__has_metric(const char *metric);
85 int arch_get_runtimeparam(const struct pmu_event *pe __maybe_unused);
86 void metricgroup__rblist_exit(struct rblist *metric_events);
88 int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp,
89 struct rblist *new_metric_events,
90 struct rblist *old_metric_events);