.. | .. |
---|
4 | 4 | |
---|
5 | 5 | #include <linux/types.h> |
---|
6 | 6 | #include <stdio.h> |
---|
7 | | -#include "xyarray.h" |
---|
| 7 | +#include <sys/types.h> |
---|
| 8 | +#include <sys/resource.h> |
---|
8 | 9 | #include "rblist.h" |
---|
| 10 | + |
---|
| 11 | +struct perf_cpu_map; |
---|
| 12 | +struct perf_stat_config; |
---|
| 13 | +struct timespec; |
---|
9 | 14 | |
---|
10 | 15 | struct stats { |
---|
11 | 16 | double n, mean, M2; |
---|
.. | .. |
---|
23 | 28 | PERF_STAT_EVSEL_ID__TOPDOWN_SLOTS_RETIRED, |
---|
24 | 29 | PERF_STAT_EVSEL_ID__TOPDOWN_FETCH_BUBBLES, |
---|
25 | 30 | 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, |
---|
26 | 35 | PERF_STAT_EVSEL_ID__SMI_NUM, |
---|
27 | 36 | PERF_STAT_EVSEL_ID__APERF, |
---|
28 | 37 | PERF_STAT_EVSEL_ID__MAX, |
---|
.. | .. |
---|
38 | 47 | AGGR_NONE, |
---|
39 | 48 | AGGR_GLOBAL, |
---|
40 | 49 | AGGR_SOCKET, |
---|
| 50 | + AGGR_DIE, |
---|
41 | 51 | AGGR_CORE, |
---|
42 | 52 | AGGR_THREAD, |
---|
43 | 53 | AGGR_UNSET, |
---|
| 54 | + AGGR_NODE, |
---|
44 | 55 | }; |
---|
45 | 56 | |
---|
46 | 57 | enum { |
---|
.. | .. |
---|
75 | 86 | STAT_TOPDOWN_SLOTS_RETIRED, |
---|
76 | 87 | STAT_TOPDOWN_FETCH_BUBBLES, |
---|
77 | 88 | STAT_TOPDOWN_RECOVERY_BUBBLES, |
---|
| 89 | + STAT_TOPDOWN_RETIRING, |
---|
| 90 | + STAT_TOPDOWN_BAD_SPEC, |
---|
| 91 | + STAT_TOPDOWN_FE_BOUND, |
---|
| 92 | + STAT_TOPDOWN_BE_BOUND, |
---|
78 | 93 | STAT_SMI_NUM, |
---|
79 | 94 | STAT_APERF, |
---|
80 | 95 | STAT_MAX |
---|
.. | .. |
---|
84 | 99 | struct rblist value_list; |
---|
85 | 100 | }; |
---|
86 | 101 | |
---|
| 102 | +typedef int (*aggr_get_id_t)(struct perf_stat_config *config, |
---|
| 103 | + struct perf_cpu_map *m, int cpu); |
---|
| 104 | + |
---|
87 | 105 | 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; |
---|
96 | 149 | }; |
---|
| 150 | + |
---|
| 151 | +void perf_stat__set_big_num(int set); |
---|
97 | 152 | |
---|
98 | 153 | void update_stats(struct stats *stats, u64 val); |
---|
99 | 154 | double avg_stats(struct stats *stats); |
---|
.. | .. |
---|
109 | 164 | stats->max = 0; |
---|
110 | 165 | } |
---|
111 | 166 | |
---|
112 | | -struct perf_evsel; |
---|
113 | | -struct perf_evlist; |
---|
| 167 | +struct evsel; |
---|
| 168 | +struct evlist; |
---|
114 | 169 | |
---|
115 | 170 | struct perf_aggr_thread_value { |
---|
116 | | - struct perf_evsel *counter; |
---|
| 171 | + struct evsel *counter; |
---|
117 | 172 | int id; |
---|
118 | 173 | double uval; |
---|
119 | 174 | u64 val; |
---|
.. | .. |
---|
121 | 176 | u64 ena; |
---|
122 | 177 | }; |
---|
123 | 178 | |
---|
124 | | -bool __perf_evsel_stat__is(struct perf_evsel *evsel, |
---|
| 179 | +bool __perf_evsel_stat__is(struct evsel *evsel, |
---|
125 | 180 | enum perf_stat_evsel_id id); |
---|
126 | 181 | |
---|
127 | 182 | #define perf_stat_evsel__is(evsel, id) \ |
---|
.. | .. |
---|
130 | 185 | extern struct runtime_stat rt_stat; |
---|
131 | 186 | extern struct stats walltime_nsecs_stats; |
---|
132 | 187 | |
---|
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, |
---|
134 | 190 | 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); |
---|
136 | 192 | |
---|
137 | 193 | void runtime_stat__init(struct runtime_stat *st); |
---|
138 | 194 | void runtime_stat__exit(struct runtime_stat *st); |
---|
139 | 195 | void perf_stat__init_shadow_stats(void); |
---|
140 | 196 | void perf_stat__reset_shadow_stats(void); |
---|
141 | 197 | 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, |
---|
143 | 199 | int cpu, struct runtime_stat *st); |
---|
144 | 200 | struct perf_stat_output_ctx { |
---|
145 | 201 | void *ctx; |
---|
.. | .. |
---|
148 | 204 | bool force_header; |
---|
149 | 205 | }; |
---|
150 | 206 | |
---|
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, |
---|
152 | 209 | double avg, int cpu, |
---|
153 | 210 | struct perf_stat_output_ctx *out, |
---|
154 | 211 | struct rblist *metric_events, |
---|
155 | 212 | struct runtime_stat *st); |
---|
156 | | -void perf_stat__collect_metric_expr(struct perf_evlist *); |
---|
| 213 | +void perf_stat__collect_metric_expr(struct evlist *); |
---|
157 | 214 | |
---|
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); |
---|
162 | 221 | |
---|
163 | 222 | int perf_stat_process_counter(struct perf_stat_config *config, |
---|
164 | | - struct perf_evsel *counter); |
---|
| 223 | + struct evsel *counter); |
---|
165 | 224 | struct perf_tool; |
---|
166 | 225 | union perf_event; |
---|
167 | 226 | 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); |
---|
171 | 231 | |
---|
172 | 232 | size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp); |
---|
173 | 233 | size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp); |
---|
174 | 234 | 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); |
---|
175 | 249 | #endif |
---|