aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2017-10-26 13:22:34 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-10-27 08:10:10 -0400
commite669e833da8d71a02e175dfffceaabc3eb010207 (patch)
tree394756927d972e8ea6e6abe247100ef6089f1e4c /tools
parent894f3f1732cb4ae543d406e4fca1585e8c303a1c (diff)
perf evsel: Restore evsel->priv as a tool private area
When we started using it for stats and did it not just in builtin-stat.c, but also for builtin-script.c, then it stopped being a tool private area, so introduce a new pointer for these stats and leave ->priv to its original purpose. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Cc: yuzhoujian <yuzhoujian@didichuxing.com> Fixes: cfc8874a4859 ("perf script: Process cpu/threads maps") Link: http://lkml.kernel.org/n/tip-jtpzx3rjqo78snmmsdzwb2eb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-stat.c4
-rw-r--r--tools/perf/util/evsel.h3
-rw-r--r--tools/perf/util/stat.c16
3 files changed, 13 insertions, 10 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index dd525417880a..988bdfa5d832 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -845,7 +845,7 @@ static void print_noise(struct perf_evsel *evsel, double avg)
845 if (run_count == 1) 845 if (run_count == 1)
846 return; 846 return;
847 847
848 ps = evsel->priv; 848 ps = evsel->stats;
849 print_noise_pct(stddev_stats(&ps->res_stats[0]), avg); 849 print_noise_pct(stddev_stats(&ps->res_stats[0]), avg);
850} 850}
851 851
@@ -1432,7 +1432,7 @@ static void counter_aggr_cb(struct perf_evsel *counter, void *data,
1432 bool first __maybe_unused) 1432 bool first __maybe_unused)
1433{ 1433{
1434 struct caggr_data *cd = data; 1434 struct caggr_data *cd = data;
1435 struct perf_stat_evsel *ps = counter->priv; 1435 struct perf_stat_evsel *ps = counter->stats;
1436 1436
1437 cd->avg += avg_stats(&ps->res_stats[0]); 1437 cd->avg += avg_stats(&ps->res_stats[0]);
1438 cd->avg_enabled += avg_stats(&ps->res_stats[1]); 1438 cd->avg_enabled += avg_stats(&ps->res_stats[1]);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index db658785d828..64782b19089d 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -68,6 +68,8 @@ struct perf_evsel_config_term {
68 } val; 68 } val;
69}; 69};
70 70
71struct perf_stat_evsel;
72
71/** struct perf_evsel - event selector 73/** struct perf_evsel - event selector
72 * 74 *
73 * @evlist - evlist this evsel is in, if it is in one. 75 * @evlist - evlist this evsel is in, if it is in one.
@@ -101,6 +103,7 @@ struct perf_evsel {
101 const char *unit; 103 const char *unit;
102 struct event_format *tp_format; 104 struct event_format *tp_format;
103 off_t id_offset; 105 off_t id_offset;
106 struct perf_stat_evsel *stats;
104 void *priv; 107 void *priv;
105 u64 db_id; 108 u64 db_id;
106 struct cgroup_sel *cgrp; 109 struct cgroup_sel *cgrp;
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 35e9848734d6..933de91831fa 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -69,7 +69,7 @@ double rel_stddev_stats(double stddev, double avg)
69bool __perf_evsel_stat__is(struct perf_evsel *evsel, 69bool __perf_evsel_stat__is(struct perf_evsel *evsel,
70 enum perf_stat_evsel_id id) 70 enum perf_stat_evsel_id id)
71{ 71{
72 struct perf_stat_evsel *ps = evsel->priv; 72 struct perf_stat_evsel *ps = evsel->stats;
73 73
74 return ps->id == id; 74 return ps->id == id;
75} 75}
@@ -93,7 +93,7 @@ static const char *id_str[PERF_STAT_EVSEL_ID__MAX] = {
93 93
94void perf_stat_evsel_id_init(struct perf_evsel *evsel) 94void perf_stat_evsel_id_init(struct perf_evsel *evsel)
95{ 95{
96 struct perf_stat_evsel *ps = evsel->priv; 96 struct perf_stat_evsel *ps = evsel->stats;
97 int i; 97 int i;
98 98
99 /* ps->id is 0 hence PERF_STAT_EVSEL_ID__NONE by default */ 99 /* ps->id is 0 hence PERF_STAT_EVSEL_ID__NONE by default */
@@ -109,7 +109,7 @@ void perf_stat_evsel_id_init(struct perf_evsel *evsel)
109static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel) 109static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
110{ 110{
111 int i; 111 int i;
112 struct perf_stat_evsel *ps = evsel->priv; 112 struct perf_stat_evsel *ps = evsel->stats;
113 113
114 for (i = 0; i < 3; i++) 114 for (i = 0; i < 3; i++)
115 init_stats(&ps->res_stats[i]); 115 init_stats(&ps->res_stats[i]);
@@ -119,8 +119,8 @@ static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
119 119
120static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel) 120static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)
121{ 121{
122 evsel->priv = zalloc(sizeof(struct perf_stat_evsel)); 122 evsel->stats = zalloc(sizeof(struct perf_stat_evsel));
123 if (evsel->priv == NULL) 123 if (evsel->stats == NULL)
124 return -ENOMEM; 124 return -ENOMEM;
125 perf_evsel__reset_stat_priv(evsel); 125 perf_evsel__reset_stat_priv(evsel);
126 return 0; 126 return 0;
@@ -128,11 +128,11 @@ static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)
128 128
129static void perf_evsel__free_stat_priv(struct perf_evsel *evsel) 129static void perf_evsel__free_stat_priv(struct perf_evsel *evsel)
130{ 130{
131 struct perf_stat_evsel *ps = evsel->priv; 131 struct perf_stat_evsel *ps = evsel->stats;
132 132
133 if (ps) 133 if (ps)
134 free(ps->group_data); 134 free(ps->group_data);
135 zfree(&evsel->priv); 135 zfree(&evsel->stats);
136} 136}
137 137
138static int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel, 138static int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel,
@@ -318,7 +318,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
318 struct perf_evsel *counter) 318 struct perf_evsel *counter)
319{ 319{
320 struct perf_counts_values *aggr = &counter->counts->aggr; 320 struct perf_counts_values *aggr = &counter->counts->aggr;
321 struct perf_stat_evsel *ps = counter->priv; 321 struct perf_stat_evsel *ps = counter->stats;
322 u64 *count = counter->counts->aggr.values; 322 u64 *count = counter->counts->aggr.values;
323 u64 val; 323 u64 val;
324 int i, ret; 324 int i, ret;