Linux Perf
pmu.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PMU_H
3 #define __PMU_H
4 
5 #include <linux/bitmap.h>
6 #include <linux/compiler.h>
7 #include <linux/perf_event.h>
8 #include <stdbool.h>
9 #include "evsel.h"
10 #include "parse-events.h"
11 
12 enum {
16 };
17 
18 #define PERF_PMU_FORMAT_BITS 64
19 
20 struct perf_event_attr;
21 
22 struct perf_pmu {
23  char *name;
24  __u32 type;
25  bool selectable;
26  bool is_uncore;
27  struct perf_event_attr *default_config;
28  struct cpu_map *cpus;
29  struct list_head format; /* HEAD struct perf_pmu_format -> list */
30  struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
31  struct list_head list; /* ELEM */
33 };
34 
35 struct perf_pmu_info {
36  const char *unit;
37  const char *metric_expr;
38  const char *metric_name;
39  double scale;
40  bool per_pkg;
41  bool snapshot;
42 };
43 
44 #define UNIT_MAX_LEN 31 /* max length for event unit name */
45 
47  char *name;
48  char *desc;
49  char *long_desc;
50  char *topic;
51  char *str;
52  struct list_head terms; /* HEAD struct parse_events_term -> list */
53  struct list_head list; /* ELEM */
54  char unit[UNIT_MAX_LEN+1];
55  double scale;
56  bool per_pkg;
57  bool snapshot;
58  char *metric_expr;
59  char *metric_name;
60 };
61 
62 struct perf_pmu *perf_pmu__find(const char *name);
63 int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
64  struct list_head *head_terms,
65  struct parse_events_error *error);
66 int perf_pmu__config_terms(struct list_head *formats,
67  struct perf_event_attr *attr,
68  struct list_head *head_terms,
69  bool zero, struct parse_events_error *error);
70 __u64 perf_pmu__format_bits(struct list_head *formats, const char *name);
71 int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
72  struct perf_pmu_info *info);
73 struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
74  struct list_head *head_terms);
75 int perf_pmu_wrap(void);
76 void perf_pmu_error(struct list_head *list, char *name, char const *msg);
77 
78 int perf_pmu__new_format(struct list_head *list, char *name,
79  int config, unsigned long *bits);
80 void perf_pmu__set_format(unsigned long *bits, long from, long to);
81 int perf_pmu__format_parse(char *dir, struct list_head *head);
82 
83 struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
84 
85 void print_pmu_events(const char *event_glob, bool name_only, bool quiet,
86  bool long_desc, bool details_flag);
87 bool pmu_have_event(const char *pname, const char *name);
88 
89 int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt, ...) __scanf(3, 4);
90 
91 int perf_pmu__test(void);
92 
93 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
94 
95 struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu);
96 
97 #endif /* __PMU_H */
bool per_pkg
Definition: pmu.h:56
char * metric_name
Definition: pmu.h:59
struct list_head list
Definition: pmu.h:31
struct pmu_events_map * perf_pmu__find_map(struct perf_pmu *pmu)
Definition: pmu.c:628
int perf_pmu__format_parse(char *dir, struct list_head *head)
Definition: pmu.c:43
bool pmu_have_event(const char *pname, const char *name)
Definition: pmu.c:1396
void print_pmu_events(const char *event_glob, bool name_only, bool quiet, bool long_desc, bool details_flag)
Definition: pmu.c:1277
static char * dir
Definition: attr.c:39
double scale
Definition: pmu.h:55
int(* set_drv_config)(struct perf_evsel_config_term *term)
Definition: pmu.h:32
int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr, struct list_head *head_terms, struct parse_events_error *error)
Definition: pmu.c:1035
void perf_pmu__set_format(unsigned long *bits, long from, long to)
Definition: pmu.c:1177
char * metric_expr
Definition: pmu.h:58
char * topic
Definition: pmu.h:50
int perf_pmu__config_terms(struct list_head *formats, struct perf_event_attr *attr, struct list_head *head_terms, bool zero, struct parse_events_error *error)
Definition: pmu.c:1014
#define config
static int term(yyscan_t scanner, int type)
struct perf_event_attr * default_config
Definition: pmu.h:27
Definition: cpumap.h:12
static bool details_flag
Definition: builtin-list.c:23
Definition: pmu.h:22
#define UNIT_MAX_LEN
Definition: pmu.h:44
struct perf_pmu * perf_pmu__find(const char *name)
Definition: pmu.c:778
struct perf_event_attr * perf_pmu__get_default_config(struct perf_pmu *pmu)
const char * fmt
Definition: dso.c:193
char * str
Definition: pmu.h:51
char * desc
Definition: pmu.h:48
const char * metric_expr
Definition: pmu.h:37
struct list_head format
Definition: pmu.h:29
double scale
Definition: pmu.h:39
bool is_uncore
Definition: pmu.h:26
int perf_pmu__new_format(struct list_head *list, char *name, int config, unsigned long *bits)
Definition: pmu.c:1160
char * name
Definition: pmu.h:23
const char * unit
Definition: pmu.h:36
__u64 perf_pmu__format_bits(struct list_head *formats, const char *name)
Definition: pmu.c:806
struct list_head aliases
Definition: pmu.h:30
struct perf_pmu * perf_pmu__scan(struct perf_pmu *pmu)
Definition: pmu.c:763
const char * metric_name
Definition: pmu.h:38
bool snapshot
Definition: pmu.h:57
char * long_desc
Definition: pmu.h:49
bool snapshot
Definition: pmu.h:41
bool selectable
Definition: pmu.h:25
int int perf_pmu__test(void)
void perf_pmu_error(struct list_head *list, char *name, char const *msg)
struct list_head * perf_pmu__alias(struct perf_pmu *pmu, struct list_head *head_terms)
Definition: attr.py:1
__u32 type
Definition: pmu.h:24
int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,...) __scanf(3
bool per_pkg
Definition: pmu.h:40
struct cpu_map * cpus
Definition: pmu.h:28
int perf_pmu_wrap(void)
bool quiet
Definition: builtin-probe.c:54
int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms, struct perf_pmu_info *info)
Definition: pmu.c:1106
char * name
Definition: pmu.h:47