^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef METRICGROUP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define METRICGROUP_H 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/rbtree.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <stdbool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "pmu-events/pmu-events.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct evlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct evsel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct evlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct rblist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct pmu_events_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct cgroup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct metric_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct rb_node nd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct evsel *evsel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct list_head head; /* list of metric_expr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct metric_ref {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) const char *metric_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) const char *metric_expr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct metric_expr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct list_head nd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) const char *metric_expr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) const char *metric_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) const char *metric_unit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct evsel **metric_events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct metric_ref *metric_refs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct metric_event *metricgroup__lookup(struct rblist *metric_events,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct evsel *evsel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) bool create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int metricgroup__parse_groups(const struct option *opt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) const char *str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) bool metric_no_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) bool metric_no_merge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct rblist *metric_events);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int metricgroup__parse_groups_test(struct evlist *evlist,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct pmu_events_map *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) const char *str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) bool metric_no_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) bool metric_no_merge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct rblist *metric_events);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) void metricgroup__print(bool metrics, bool groups, char *filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) bool raw, bool details);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) bool metricgroup__has_metric(const char *metric);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) int arch_get_runtimeparam(struct pmu_event *pe __maybe_unused);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void metricgroup__rblist_exit(struct rblist *metric_events);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct rblist *new_metric_events,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct rblist *old_metric_events);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #endif