1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/types.h>
15 enum perf_stat_evsel_id
{
16 PERF_STAT_EVSEL_ID__NONE
= 0,
17 PERF_STAT_EVSEL_ID__CYCLES_IN_TX
,
18 PERF_STAT_EVSEL_ID__TRANSACTION_START
,
19 PERF_STAT_EVSEL_ID__ELISION_START
,
20 PERF_STAT_EVSEL_ID__CYCLES_IN_TX_CP
,
21 PERF_STAT_EVSEL_ID__TOPDOWN_TOTAL_SLOTS
,
22 PERF_STAT_EVSEL_ID__TOPDOWN_SLOTS_ISSUED
,
23 PERF_STAT_EVSEL_ID__TOPDOWN_SLOTS_RETIRED
,
24 PERF_STAT_EVSEL_ID__TOPDOWN_FETCH_BUBBLES
,
25 PERF_STAT_EVSEL_ID__TOPDOWN_RECOVERY_BUBBLES
,
26 PERF_STAT_EVSEL_ID__SMI_NUM
,
27 PERF_STAT_EVSEL_ID__APERF
,
28 PERF_STAT_EVSEL_ID__MAX
,
31 struct perf_stat_evsel
{
32 struct stats res_stats
[3];
33 enum perf_stat_evsel_id id
;
46 struct perf_stat_config
{
47 enum aggr_mode aggr_mode
;
50 unsigned int interval
;
53 void update_stats(struct stats
*stats
, u64 val
);
54 double avg_stats(struct stats
*stats
);
55 double stddev_stats(struct stats
*stats
);
56 double rel_stddev_stats(double stddev
, double avg
);
58 static inline void init_stats(struct stats
*stats
)
63 stats
->min
= (u64
) -1;
70 bool __perf_evsel_stat__is(struct perf_evsel
*evsel
,
71 enum perf_stat_evsel_id id
);
73 #define perf_stat_evsel__is(evsel, id) \
74 __perf_evsel_stat__is(evsel, PERF_STAT_EVSEL_ID__ ## id)
76 void perf_stat_evsel_id_init(struct perf_evsel
*evsel
);
78 extern struct stats walltime_nsecs_stats
;
80 typedef void (*print_metric_t
)(void *ctx
, const char *color
, const char *unit
,
81 const char *fmt
, double val
);
82 typedef void (*new_line_t
)(void *ctx
);
84 void perf_stat__init_shadow_stats(void);
85 void perf_stat__reset_shadow_stats(void);
86 void perf_stat__update_shadow_stats(struct perf_evsel
*counter
, u64
*count
,
88 struct perf_stat_output_ctx
{
90 print_metric_t print_metric
;
95 void perf_stat__print_shadow_stats(struct perf_evsel
*evsel
,
97 struct perf_stat_output_ctx
*out
);
98 void perf_stat__collect_metric_expr(struct perf_evlist
*);
100 int perf_evlist__alloc_stats(struct perf_evlist
*evlist
, bool alloc_raw
);
101 void perf_evlist__free_stats(struct perf_evlist
*evlist
);
102 void perf_evlist__reset_stats(struct perf_evlist
*evlist
);
104 int perf_stat_process_counter(struct perf_stat_config
*config
,
105 struct perf_evsel
*counter
);
109 int perf_event__process_stat_event(struct perf_tool
*tool
,
110 union perf_event
*event
,
111 struct perf_session
*session
);
113 size_t perf_event__fprintf_stat(union perf_event
*event
, FILE *fp
);
114 size_t perf_event__fprintf_stat_round(union perf_event
*event
, FILE *fp
);
115 size_t perf_event__fprintf_stat_config(union perf_event
*event
, FILE *fp
);