diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-11-21 17:22:21 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-11-21 17:22:21 -0800 |
| commit | 4843f6873f7c4835e62f2c73ba0fd538e57a2f22 (patch) | |
| tree | ee620501a1ffbad9a83141e3a70154e1fe641040 /tools/perf/util/metricgroup.h | |
| download | linux-master.tar.gz linux-master.zip | |
Merge tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctlgraftedHEADmaster
Pull sysctl fix from Joel Granados:
"Fix sysctl jiffy / milliseconds conversion:
- Writing a previously read value "X" shall keep the same "X" value
- Remove truncation that was causing incorrect saturation of valid
timeouts"
* tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl:
sysctl: Do jiffy / ms conversion in ulong space
Diffstat (limited to 'tools/perf/util/metricgroup.h')
| -rw-r--r-- | tools/perf/util/metricgroup.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h new file mode 100644 index 000000000..6a66f14dd --- /dev/null +++ b/tools/perf/util/metricgroup.h @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0-only +#ifndef METRICGROUP_H +#define METRICGROUP_H 1 + +#include <linux/list.h> +#include <linux/rbtree.h> +#include <stdbool.h> +#include "pmu-events/pmu-events.h" + +struct evlist; +struct evsel; +struct option; +struct print_callbacks; +struct rblist; +struct cgroup; + +/** + * A node in a rblist keyed by the evsel. The global rblist of metric events + * generally exists in evlist. The evsel is looked up in the rblist + * yielding a list of metric_expr. + */ +struct metric_event { + struct rb_node nd; + struct evsel *evsel; + bool is_default; /* the metric evsel from the Default metricgroup */ + struct list_head head; /* list of metric_expr */ +}; + +/** + * A metric referenced by a metric_expr. When parsing a metric expression IDs + * will be looked up, matching either a value (from metric_events) or a + * metric_ref. A metric_ref will then be parsed recursively. The metric_refs and + * metric_events need to be known before parsing so that their values may be + * placed in the parse context for lookup. + */ +struct metric_ref { + const char *metric_name; + const char *metric_expr; +}; + +/** + * One in a list of metric_expr associated with an evsel. The data is used to + * generate a metric value during stat output. + */ +struct metric_expr { + struct list_head nd; + /** The expression to parse, for example, "instructions/cycles". */ + const char *metric_expr; + /** The name of the meric such as "IPC". */ + const char *metric_name; + const char *metric_threshold; + /** + * The "ScaleUnit" that scales and adds a unit to the metric during + * output. For example, "6.4e-05MiB" means to scale the resulting metric + * by 6.4e-05 (typically converting a unit like cache lines to something + * more human intelligible) and then add "MiB" afterward when displayed. + */ + const char *metric_unit; + /** Displayed metricgroup name of the Default metricgroup */ + const char *default_metricgroup_name; + /** Null terminated array of events used by the metric. */ + struct evsel **metric_events; + /** Null terminated array of referenced metrics. */ + struct metric_ref *metric_refs; + /** A value substituted for '?' during parsing. */ + int runtime; +}; + +struct metric_event *metricgroup__lookup(struct rblist *metric_events, + struct evsel *evsel, + bool create); +int metricgroup__parse_groups(struct evlist *perf_evlist, + const char *pmu, + bool cputype_filter, + const char *str, + bool metric_no_group, + bool metric_no_merge, + bool metric_no_threshold, + const char *user_requested_cpu_list, + bool system_wide, + bool hardware_aware_grouping); +int metricgroup__parse_groups_test(struct evlist *evlist, + const struct pmu_metrics_table *table, + const char *str, + bool cputype_filter); + +int metricgroup__for_each_metric(const struct pmu_metrics_table *table, pmu_metric_iter_fn fn, + void *data); +bool metricgroup__has_metric_or_groups(const char *pmu, const char *metric_or_groups); +unsigned int metricgroups__topdown_max_level(void); +int arch_get_runtimeparam(const struct pmu_metric *pm); +void metricgroup__rblist_init(struct rblist *metric_events); +void metricgroup__rblist_exit(struct rblist *metric_events); + +int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, + struct rblist *new_metric_events, + struct rblist *old_metric_events); +#endif |
