hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/tools/perf/util/stat.h
....@@ -4,8 +4,13 @@
44
55 #include <linux/types.h>
66 #include <stdio.h>
7
-#include "xyarray.h"
7
+#include <sys/types.h>
8
+#include <sys/resource.h>
89 #include "rblist.h"
10
+
11
+struct perf_cpu_map;
12
+struct perf_stat_config;
13
+struct timespec;
914
1015 struct stats {
1116 double n, mean, M2;
....@@ -23,6 +28,10 @@
2328 PERF_STAT_EVSEL_ID__TOPDOWN_SLOTS_RETIRED,
2429 PERF_STAT_EVSEL_ID__TOPDOWN_FETCH_BUBBLES,
2530 PERF_STAT_EVSEL_ID__TOPDOWN_RECOVERY_BUBBLES,
31
+ PERF_STAT_EVSEL_ID__TOPDOWN_RETIRING,
32
+ PERF_STAT_EVSEL_ID__TOPDOWN_BAD_SPEC,
33
+ PERF_STAT_EVSEL_ID__TOPDOWN_FE_BOUND,
34
+ PERF_STAT_EVSEL_ID__TOPDOWN_BE_BOUND,
2635 PERF_STAT_EVSEL_ID__SMI_NUM,
2736 PERF_STAT_EVSEL_ID__APERF,
2837 PERF_STAT_EVSEL_ID__MAX,
....@@ -38,9 +47,11 @@
3847 AGGR_NONE,
3948 AGGR_GLOBAL,
4049 AGGR_SOCKET,
50
+ AGGR_DIE,
4151 AGGR_CORE,
4252 AGGR_THREAD,
4353 AGGR_UNSET,
54
+ AGGR_NODE,
4455 };
4556
4657 enum {
....@@ -75,6 +86,10 @@
7586 STAT_TOPDOWN_SLOTS_RETIRED,
7687 STAT_TOPDOWN_FETCH_BUBBLES,
7788 STAT_TOPDOWN_RECOVERY_BUBBLES,
89
+ STAT_TOPDOWN_RETIRING,
90
+ STAT_TOPDOWN_BAD_SPEC,
91
+ STAT_TOPDOWN_FE_BOUND,
92
+ STAT_TOPDOWN_BE_BOUND,
7893 STAT_SMI_NUM,
7994 STAT_APERF,
8095 STAT_MAX
....@@ -84,16 +99,56 @@
8499 struct rblist value_list;
85100 };
86101
102
+typedef int (*aggr_get_id_t)(struct perf_stat_config *config,
103
+ struct perf_cpu_map *m, int cpu);
104
+
87105 struct perf_stat_config {
88
- enum aggr_mode aggr_mode;
89
- bool scale;
90
- FILE *output;
91
- unsigned int interval;
92
- unsigned int timeout;
93
- int times;
94
- struct runtime_stat *stats;
95
- int stats_num;
106
+ enum aggr_mode aggr_mode;
107
+ bool scale;
108
+ bool no_inherit;
109
+ bool identifier;
110
+ bool csv_output;
111
+ bool interval_clear;
112
+ bool metric_only;
113
+ bool null_run;
114
+ bool ru_display;
115
+ bool big_num;
116
+ bool no_merge;
117
+ bool walltime_run_table;
118
+ bool all_kernel;
119
+ bool all_user;
120
+ bool percore_show_thread;
121
+ bool summary;
122
+ bool metric_no_group;
123
+ bool metric_no_merge;
124
+ bool stop_read_counter;
125
+ FILE *output;
126
+ unsigned int interval;
127
+ unsigned int timeout;
128
+ int initial_delay;
129
+ unsigned int unit_width;
130
+ unsigned int metric_only_len;
131
+ int times;
132
+ int run_count;
133
+ int print_free_counters_hint;
134
+ int print_mixed_hw_group_error;
135
+ struct runtime_stat *stats;
136
+ int stats_num;
137
+ const char *csv_sep;
138
+ struct stats *walltime_nsecs_stats;
139
+ struct rusage ru_data;
140
+ struct perf_cpu_map *aggr_map;
141
+ aggr_get_id_t aggr_get_id;
142
+ struct perf_cpu_map *cpus_aggr_map;
143
+ u64 *walltime_run;
144
+ struct rblist metric_events;
145
+ int ctl_fd;
146
+ int ctl_fd_ack;
147
+ bool ctl_fd_close;
148
+ const char *cgroup_list;
96149 };
150
+
151
+void perf_stat__set_big_num(int set);
97152
98153 void update_stats(struct stats *stats, u64 val);
99154 double avg_stats(struct stats *stats);
....@@ -109,11 +164,11 @@
109164 stats->max = 0;
110165 }
111166
112
-struct perf_evsel;
113
-struct perf_evlist;
167
+struct evsel;
168
+struct evlist;
114169
115170 struct perf_aggr_thread_value {
116
- struct perf_evsel *counter;
171
+ struct evsel *counter;
117172 int id;
118173 double uval;
119174 u64 val;
....@@ -121,7 +176,7 @@
121176 u64 ena;
122177 };
123178
124
-bool __perf_evsel_stat__is(struct perf_evsel *evsel,
179
+bool __perf_evsel_stat__is(struct evsel *evsel,
125180 enum perf_stat_evsel_id id);
126181
127182 #define perf_stat_evsel__is(evsel, id) \
....@@ -130,16 +185,17 @@
130185 extern struct runtime_stat rt_stat;
131186 extern struct stats walltime_nsecs_stats;
132187
133
-typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit,
188
+typedef void (*print_metric_t)(struct perf_stat_config *config,
189
+ void *ctx, const char *color, const char *unit,
134190 const char *fmt, double val);
135
-typedef void (*new_line_t )(void *ctx);
191
+typedef void (*new_line_t)(struct perf_stat_config *config, void *ctx);
136192
137193 void runtime_stat__init(struct runtime_stat *st);
138194 void runtime_stat__exit(struct runtime_stat *st);
139195 void perf_stat__init_shadow_stats(void);
140196 void perf_stat__reset_shadow_stats(void);
141197 void perf_stat__reset_shadow_per_stat(struct runtime_stat *st);
142
-void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count,
198
+void perf_stat__update_shadow_stats(struct evsel *counter, u64 count,
143199 int cpu, struct runtime_stat *st);
144200 struct perf_stat_output_ctx {
145201 void *ctx;
....@@ -148,28 +204,46 @@
148204 bool force_header;
149205 };
150206
151
-void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
207
+void perf_stat__print_shadow_stats(struct perf_stat_config *config,
208
+ struct evsel *evsel,
152209 double avg, int cpu,
153210 struct perf_stat_output_ctx *out,
154211 struct rblist *metric_events,
155212 struct runtime_stat *st);
156
-void perf_stat__collect_metric_expr(struct perf_evlist *);
213
+void perf_stat__collect_metric_expr(struct evlist *);
157214
158
-int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);
159
-void perf_evlist__free_stats(struct perf_evlist *evlist);
160
-void perf_evlist__reset_stats(struct perf_evlist *evlist);
161
-void perf_evlist__reset_prev_raw_counts(struct perf_evlist *evlist);
215
+int perf_evlist__alloc_stats(struct evlist *evlist, bool alloc_raw);
216
+void perf_evlist__free_stats(struct evlist *evlist);
217
+void perf_evlist__reset_stats(struct evlist *evlist);
218
+void perf_evlist__reset_prev_raw_counts(struct evlist *evlist);
219
+void perf_evlist__copy_prev_raw_counts(struct evlist *evlist);
220
+void perf_evlist__save_aggr_prev_raw_counts(struct evlist *evlist);
162221
163222 int perf_stat_process_counter(struct perf_stat_config *config,
164
- struct perf_evsel *counter);
223
+ struct evsel *counter);
165224 struct perf_tool;
166225 union perf_event;
167226 struct perf_session;
168
-int perf_event__process_stat_event(struct perf_tool *tool,
169
- union perf_event *event,
170
- struct perf_session *session);
227
+struct target;
228
+
229
+int perf_event__process_stat_event(struct perf_session *session,
230
+ union perf_event *event);
171231
172232 size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp);
173233 size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp);
174234 size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp);
235
+
236
+int create_perf_stat_counter(struct evsel *evsel,
237
+ struct perf_stat_config *config,
238
+ struct target *target,
239
+ int cpu);
240
+void
241
+perf_evlist__print_counters(struct evlist *evlist,
242
+ struct perf_stat_config *config,
243
+ struct target *_target,
244
+ struct timespec *ts,
245
+ int argc, const char **argv);
246
+
247
+struct metric_expr;
248
+double test_generic_metric(struct metric_expr *mexp, int cpu, struct runtime_stat *st);
175249 #endif