Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+13 -10
+2 -2
tools/perf/builtin-stat.c
··· 845 845 if (run_count == 1) 846 846 return; 847 847 848 - ps = evsel->priv; 848 + ps = evsel->stats; 849 849 print_noise_pct(stddev_stats(&ps->res_stats[0]), avg); 850 850 } 851 851 ··· 1432 1432 bool first __maybe_unused) 1433 1433 { 1434 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 1437 cd->avg += avg_stats(&ps->res_stats[0]); 1438 1438 cd->avg_enabled += avg_stats(&ps->res_stats[1]);
+3
tools/perf/util/evsel.h
··· 68 68 } val; 69 69 }; 70 70 71 + struct perf_stat_evsel; 72 + 71 73 /** struct perf_evsel - event selector 72 74 * 73 75 * @evlist - evlist this evsel is in, if it is in one. ··· 103 101 const char *unit; 104 102 struct event_format *tp_format; 105 103 off_t id_offset; 104 + struct perf_stat_evsel *stats; 106 105 void *priv; 107 106 u64 db_id; 108 107 struct cgroup_sel *cgrp;
+8 -8
tools/perf/util/stat.c
··· 69 69 bool __perf_evsel_stat__is(struct perf_evsel *evsel, 70 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 74 return ps->id == id; 75 75 } ··· 93 93 94 94 void 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 97 int i; 98 98 99 99 /* ps->id is 0 hence PERF_STAT_EVSEL_ID__NONE by default */ ··· 109 109 static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel) 110 110 { 111 111 int i; 112 - struct perf_stat_evsel *ps = evsel->priv; 112 + struct perf_stat_evsel *ps = evsel->stats; 113 113 114 114 for (i = 0; i < 3; i++) 115 115 init_stats(&ps->res_stats[i]); ··· 119 119 120 120 static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel) 121 121 { 122 - evsel->priv = zalloc(sizeof(struct perf_stat_evsel)); 123 - if (evsel->priv == NULL) 122 + evsel->stats = zalloc(sizeof(struct perf_stat_evsel)); 123 + if (evsel->stats == NULL) 124 124 return -ENOMEM; 125 125 perf_evsel__reset_stat_priv(evsel); 126 126 return 0; ··· 128 128 129 129 static 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 133 if (ps) 134 134 free(ps->group_data); 135 - zfree(&evsel->priv); 135 + zfree(&evsel->stats); 136 136 } 137 137 138 138 static int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel, ··· 318 318 struct perf_evsel *counter) 319 319 { 320 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 322 u64 *count = counter->counts->aggr.values; 323 323 u64 val; 324 324 int i, ret;