]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - tools/perf/util/stat.h
Merge tag 'for-linus-4.8b-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-artful-kernel.git] / tools / perf / util / stat.h
CommitLineData
0007ecea
XG
1#ifndef __PERF_STATS_H
2#define __PERF_STATS_H
3
d944c4ee 4#include <linux/types.h>
f87027b9 5#include <stdio.h>
a8e02324 6#include "xyarray.h"
0007ecea
XG
7
8struct stats
9{
10 double n, mean, M2;
ffe4f3c0 11 u64 max, min;
0007ecea
XG
12};
13
e2f56da1
JO
14enum perf_stat_evsel_id {
15 PERF_STAT_EVSEL_ID__NONE = 0,
4c358d5c
JO
16 PERF_STAT_EVSEL_ID__CYCLES_IN_TX,
17 PERF_STAT_EVSEL_ID__TRANSACTION_START,
18 PERF_STAT_EVSEL_ID__ELISION_START,
19 PERF_STAT_EVSEL_ID__CYCLES_IN_TX_CP,
239bd47f
AK
20 PERF_STAT_EVSEL_ID__TOPDOWN_TOTAL_SLOTS,
21 PERF_STAT_EVSEL_ID__TOPDOWN_SLOTS_ISSUED,
22 PERF_STAT_EVSEL_ID__TOPDOWN_SLOTS_RETIRED,
23 PERF_STAT_EVSEL_ID__TOPDOWN_FETCH_BUBBLES,
24 PERF_STAT_EVSEL_ID__TOPDOWN_RECOVERY_BUBBLES,
e2f56da1
JO
25 PERF_STAT_EVSEL_ID__MAX,
26};
27
581cc8a2 28struct perf_stat_evsel {
e2f56da1
JO
29 struct stats res_stats[3];
30 enum perf_stat_evsel_id id;
31};
32
f87027b9
JO
33enum aggr_mode {
34 AGGR_NONE,
35 AGGR_GLOBAL,
36 AGGR_SOCKET,
37 AGGR_CORE,
32b8af82 38 AGGR_THREAD,
208df99e 39 AGGR_UNSET,
f87027b9
JO
40};
41
421a50f3
JO
42struct perf_stat_config {
43 enum aggr_mode aggr_mode;
711a572e 44 bool scale;
5821522e 45 FILE *output;
ec0d3d1f 46 unsigned int interval;
421a50f3
JO
47};
48
0007ecea
XG
49void update_stats(struct stats *stats, u64 val);
50double avg_stats(struct stats *stats);
51double stddev_stats(struct stats *stats);
52double rel_stddev_stats(double stddev, double avg);
53
ffe4f3c0
DA
54static inline void init_stats(struct stats *stats)
55{
56 stats->n = 0.0;
57 stats->mean = 0.0;
58 stats->M2 = 0.0;
59 stats->min = (u64) -1;
60 stats->max = 0;
61}
e2f56da1
JO
62
63struct perf_evsel;
24e34f68
JO
64struct perf_evlist;
65
e2f56da1
JO
66bool __perf_evsel_stat__is(struct perf_evsel *evsel,
67 enum perf_stat_evsel_id id);
68
69#define perf_stat_evsel__is(evsel, id) \
70 __perf_evsel_stat__is(evsel, PERF_STAT_EVSEL_ID__ ## id)
71
72void perf_stat_evsel_id_init(struct perf_evsel *evsel);
73
f87027b9
JO
74extern struct stats walltime_nsecs_stats;
75
140aeadc
AK
76typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit,
77 const char *fmt, double val);
78typedef void (*new_line_t )(void *ctx);
79
fb4605ba 80void perf_stat__init_shadow_stats(void);
f87027b9
JO
81void perf_stat__reset_shadow_stats(void);
82void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
83 int cpu);
140aeadc
AK
84struct perf_stat_output_ctx {
85 void *ctx;
86 print_metric_t print_metric;
87 new_line_t new_line;
88};
89
90void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
91 double avg, int cpu,
92 struct perf_stat_output_ctx *out);
f87027b9 93
24e34f68
JO
94int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);
95void perf_evlist__free_stats(struct perf_evlist *evlist);
96void perf_evlist__reset_stats(struct perf_evlist *evlist);
f80010eb
JO
97
98int perf_stat_process_counter(struct perf_stat_config *config,
99 struct perf_evsel *counter);
0ea0e355
JO
100struct perf_tool;
101union perf_event;
102struct perf_session;
103int perf_event__process_stat_event(struct perf_tool *tool,
104 union perf_event *event,
105 struct perf_session *session);
e08a4564
JO
106
107size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp);
108size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp);
109size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp);
0007ecea 110#endif