aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/stat.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/stat.h')
-rw-r--r--tools/perf/util/stat.h63
1 files changed, 60 insertions, 3 deletions
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index eefca5c981fd..dbc6f7134f61 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -5,6 +5,7 @@
5#include <linux/types.h> 5#include <linux/types.h>
6#include <stdio.h> 6#include <stdio.h>
7#include "xyarray.h" 7#include "xyarray.h"
8#include "rblist.h"
8 9
9struct stats 10struct stats
10{ 11{
@@ -43,11 +44,54 @@ enum aggr_mode {
43 AGGR_UNSET, 44 AGGR_UNSET,
44}; 45};
45 46
47enum {
48 CTX_BIT_USER = 1 << 0,
49 CTX_BIT_KERNEL = 1 << 1,
50 CTX_BIT_HV = 1 << 2,
51 CTX_BIT_HOST = 1 << 3,
52 CTX_BIT_IDLE = 1 << 4,
53 CTX_BIT_MAX = 1 << 5,
54};
55
56#define NUM_CTX CTX_BIT_MAX
57
58enum stat_type {
59 STAT_NONE = 0,
60 STAT_NSECS,
61 STAT_CYCLES,
62 STAT_STALLED_CYCLES_FRONT,
63 STAT_STALLED_CYCLES_BACK,
64 STAT_BRANCHES,
65 STAT_CACHEREFS,
66 STAT_L1_DCACHE,
67 STAT_L1_ICACHE,
68 STAT_LL_CACHE,
69 STAT_ITLB_CACHE,
70 STAT_DTLB_CACHE,
71 STAT_CYCLES_IN_TX,
72 STAT_TRANSACTION,
73 STAT_ELISION,
74 STAT_TOPDOWN_TOTAL_SLOTS,
75 STAT_TOPDOWN_SLOTS_ISSUED,
76 STAT_TOPDOWN_SLOTS_RETIRED,
77 STAT_TOPDOWN_FETCH_BUBBLES,
78 STAT_TOPDOWN_RECOVERY_BUBBLES,
79 STAT_SMI_NUM,
80 STAT_APERF,
81 STAT_MAX
82};
83
84struct runtime_stat {
85 struct rblist value_list;
86};
87
46struct perf_stat_config { 88struct perf_stat_config {
47 enum aggr_mode aggr_mode; 89 enum aggr_mode aggr_mode;
48 bool scale; 90 bool scale;
49 FILE *output; 91 FILE *output;
50 unsigned int interval; 92 unsigned int interval;
93 struct runtime_stat *stats;
94 int stats_num;
51}; 95};
52 96
53void update_stats(struct stats *stats, u64 val); 97void update_stats(struct stats *stats, u64 val);
@@ -67,6 +111,15 @@ static inline void init_stats(struct stats *stats)
67struct perf_evsel; 111struct perf_evsel;
68struct perf_evlist; 112struct perf_evlist;
69 113
114struct perf_aggr_thread_value {
115 struct perf_evsel *counter;
116 int id;
117 double uval;
118 u64 val;
119 u64 run;
120 u64 ena;
121};
122
70bool __perf_evsel_stat__is(struct perf_evsel *evsel, 123bool __perf_evsel_stat__is(struct perf_evsel *evsel,
71 enum perf_stat_evsel_id id); 124 enum perf_stat_evsel_id id);
72 125
@@ -75,16 +128,20 @@ bool __perf_evsel_stat__is(struct perf_evsel *evsel,
75 128
76void perf_stat_evsel_id_init(struct perf_evsel *evsel); 129void perf_stat_evsel_id_init(struct perf_evsel *evsel);
77 130
131extern struct runtime_stat rt_stat;
78extern struct stats walltime_nsecs_stats; 132extern struct stats walltime_nsecs_stats;
79 133
80typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit, 134typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit,
81 const char *fmt, double val); 135 const char *fmt, double val);
82typedef void (*new_line_t )(void *ctx); 136typedef void (*new_line_t )(void *ctx);
83 137
138void runtime_stat__init(struct runtime_stat *st);
139void runtime_stat__exit(struct runtime_stat *st);
84void perf_stat__init_shadow_stats(void); 140void perf_stat__init_shadow_stats(void);
85void perf_stat__reset_shadow_stats(void); 141void perf_stat__reset_shadow_stats(void);
142void perf_stat__reset_shadow_per_stat(struct runtime_stat *st);
86void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count, 143void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count,
87 int cpu); 144 int cpu, struct runtime_stat *st);
88struct perf_stat_output_ctx { 145struct perf_stat_output_ctx {
89 void *ctx; 146 void *ctx;
90 print_metric_t print_metric; 147 print_metric_t print_metric;
@@ -92,11 +149,11 @@ struct perf_stat_output_ctx {
92 bool force_header; 149 bool force_header;
93}; 150};
94 151
95struct rblist;
96void perf_stat__print_shadow_stats(struct perf_evsel *evsel, 152void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
97 double avg, int cpu, 153 double avg, int cpu,
98 struct perf_stat_output_ctx *out, 154 struct perf_stat_output_ctx *out,
99 struct rblist *metric_events); 155 struct rblist *metric_events,
156 struct runtime_stat *st);
100void perf_stat__collect_metric_expr(struct perf_evlist *); 157void perf_stat__collect_metric_expr(struct perf_evlist *);
101 158
102int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw); 159int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);