diff options
author | Jiri Olsa <jolsa@kernel.org> | 2017-01-23 16:42:56 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-10-30 12:40:33 -0400 |
commit | 54830dd0c342525de2ff10f8be7cf0a9f062b896 (patch) | |
tree | 52f57c985373b37014f824cba0d4f4e0efc0f169 | |
parent | e268687bfb73bb7bfe65f23f5cba5c8a0e5bb050 (diff) |
perf stat: Move the shadow stats scale computation in perf_stat__update_shadow_stats
Move the shadow stats scale computation to the
perf_stat__update_shadow_stats() function, so it's centralized and we
don't forget to do it. It also saves few lines of code.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Changbin Du <changbin.du@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-htg7mmyxv6pcrf57qyo6msid@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-stat.c | 3 | ||||
-rw-r--r-- | tools/perf/util/stat-shadow.c | 48 | ||||
-rw-r--r-- | tools/perf/util/stat.c | 6 | ||||
-rw-r--r-- | tools/perf/util/stat.h | 2 |
4 files changed, 29 insertions, 30 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index fa5896270022..59af5a8419e2 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -1267,8 +1267,7 @@ static void aggr_update_shadow(void) | |||
1267 | continue; | 1267 | continue; |
1268 | val += perf_counts(counter->counts, cpu, 0)->val; | 1268 | val += perf_counts(counter->counts, cpu, 0)->val; |
1269 | } | 1269 | } |
1270 | val = val * counter->scale; | 1270 | perf_stat__update_shadow_stats(counter, val, |
1271 | perf_stat__update_shadow_stats(counter, &val, | ||
1272 | first_shadow_cpu(counter, id)); | 1271 | first_shadow_cpu(counter, id)); |
1273 | } | 1272 | } |
1274 | } | 1273 | } |
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index a2c12d1ef32a..51ad03a799ec 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c | |||
@@ -178,58 +178,60 @@ void perf_stat__reset_shadow_stats(void) | |||
178 | * more semantic information such as miss/hit ratios, | 178 | * more semantic information such as miss/hit ratios, |
179 | * instruction rates, etc: | 179 | * instruction rates, etc: |
180 | */ | 180 | */ |
181 | void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, | 181 | void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count, |
182 | int cpu) | 182 | int cpu) |
183 | { | 183 | { |
184 | int ctx = evsel_context(counter); | 184 | int ctx = evsel_context(counter); |
185 | 185 | ||
186 | count *= counter->scale; | ||
187 | |||
186 | if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK) || | 188 | if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK) || |
187 | perf_evsel__match(counter, SOFTWARE, SW_CPU_CLOCK)) | 189 | perf_evsel__match(counter, SOFTWARE, SW_CPU_CLOCK)) |
188 | update_stats(&runtime_nsecs_stats[cpu], count[0]); | 190 | update_stats(&runtime_nsecs_stats[cpu], count); |
189 | else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) | 191 | else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) |
190 | update_stats(&runtime_cycles_stats[ctx][cpu], count[0]); | 192 | update_stats(&runtime_cycles_stats[ctx][cpu], count); |
191 | else if (perf_stat_evsel__is(counter, CYCLES_IN_TX)) | 193 | else if (perf_stat_evsel__is(counter, CYCLES_IN_TX)) |
192 | update_stats(&runtime_cycles_in_tx_stats[ctx][cpu], count[0]); | 194 | update_stats(&runtime_cycles_in_tx_stats[ctx][cpu], count); |
193 | else if (perf_stat_evsel__is(counter, TRANSACTION_START)) | 195 | else if (perf_stat_evsel__is(counter, TRANSACTION_START)) |
194 | update_stats(&runtime_transaction_stats[ctx][cpu], count[0]); | 196 | update_stats(&runtime_transaction_stats[ctx][cpu], count); |
195 | else if (perf_stat_evsel__is(counter, ELISION_START)) | 197 | else if (perf_stat_evsel__is(counter, ELISION_START)) |
196 | update_stats(&runtime_elision_stats[ctx][cpu], count[0]); | 198 | update_stats(&runtime_elision_stats[ctx][cpu], count); |
197 | else if (perf_stat_evsel__is(counter, TOPDOWN_TOTAL_SLOTS)) | 199 | else if (perf_stat_evsel__is(counter, TOPDOWN_TOTAL_SLOTS)) |
198 | update_stats(&runtime_topdown_total_slots[ctx][cpu], count[0]); | 200 | update_stats(&runtime_topdown_total_slots[ctx][cpu], count); |
199 | else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_ISSUED)) | 201 | else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_ISSUED)) |
200 | update_stats(&runtime_topdown_slots_issued[ctx][cpu], count[0]); | 202 | update_stats(&runtime_topdown_slots_issued[ctx][cpu], count); |
201 | else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_RETIRED)) | 203 | else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_RETIRED)) |
202 | update_stats(&runtime_topdown_slots_retired[ctx][cpu], count[0]); | 204 | update_stats(&runtime_topdown_slots_retired[ctx][cpu], count); |
203 | else if (perf_stat_evsel__is(counter, TOPDOWN_FETCH_BUBBLES)) | 205 | else if (perf_stat_evsel__is(counter, TOPDOWN_FETCH_BUBBLES)) |
204 | update_stats(&runtime_topdown_fetch_bubbles[ctx][cpu],count[0]); | 206 | update_stats(&runtime_topdown_fetch_bubbles[ctx][cpu], count); |
205 | else if (perf_stat_evsel__is(counter, TOPDOWN_RECOVERY_BUBBLES)) | 207 | else if (perf_stat_evsel__is(counter, TOPDOWN_RECOVERY_BUBBLES)) |
206 | update_stats(&runtime_topdown_recovery_bubbles[ctx][cpu], count[0]); | 208 | update_stats(&runtime_topdown_recovery_bubbles[ctx][cpu], count); |
207 | else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) | 209 | else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) |
208 | update_stats(&runtime_stalled_cycles_front_stats[ctx][cpu], count[0]); | 210 | update_stats(&runtime_stalled_cycles_front_stats[ctx][cpu], count); |
209 | else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_BACKEND)) | 211 | else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_BACKEND)) |
210 | update_stats(&runtime_stalled_cycles_back_stats[ctx][cpu], count[0]); | 212 | update_stats(&runtime_stalled_cycles_back_stats[ctx][cpu], count); |
211 | else if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS)) | 213 | else if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS)) |
212 | update_stats(&runtime_branches_stats[ctx][cpu], count[0]); | 214 | update_stats(&runtime_branches_stats[ctx][cpu], count); |
213 | else if (perf_evsel__match(counter, HARDWARE, HW_CACHE_REFERENCES)) | 215 | else if (perf_evsel__match(counter, HARDWARE, HW_CACHE_REFERENCES)) |
214 | update_stats(&runtime_cacherefs_stats[ctx][cpu], count[0]); | 216 | update_stats(&runtime_cacherefs_stats[ctx][cpu], count); |
215 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_L1D)) | 217 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_L1D)) |
216 | update_stats(&runtime_l1_dcache_stats[ctx][cpu], count[0]); | 218 | update_stats(&runtime_l1_dcache_stats[ctx][cpu], count); |
217 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_L1I)) | 219 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_L1I)) |
218 | update_stats(&runtime_ll_cache_stats[ctx][cpu], count[0]); | 220 | update_stats(&runtime_ll_cache_stats[ctx][cpu], count); |
219 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_LL)) | 221 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_LL)) |
220 | update_stats(&runtime_ll_cache_stats[ctx][cpu], count[0]); | 222 | update_stats(&runtime_ll_cache_stats[ctx][cpu], count); |
221 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_DTLB)) | 223 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_DTLB)) |
222 | update_stats(&runtime_dtlb_cache_stats[ctx][cpu], count[0]); | 224 | update_stats(&runtime_dtlb_cache_stats[ctx][cpu], count); |
223 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_ITLB)) | 225 | else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_ITLB)) |
224 | update_stats(&runtime_itlb_cache_stats[ctx][cpu], count[0]); | 226 | update_stats(&runtime_itlb_cache_stats[ctx][cpu], count); |
225 | else if (perf_stat_evsel__is(counter, SMI_NUM)) | 227 | else if (perf_stat_evsel__is(counter, SMI_NUM)) |
226 | update_stats(&runtime_smi_num_stats[ctx][cpu], count[0]); | 228 | update_stats(&runtime_smi_num_stats[ctx][cpu], count); |
227 | else if (perf_stat_evsel__is(counter, APERF)) | 229 | else if (perf_stat_evsel__is(counter, APERF)) |
228 | update_stats(&runtime_aperf_stats[ctx][cpu], count[0]); | 230 | update_stats(&runtime_aperf_stats[ctx][cpu], count); |
229 | 231 | ||
230 | if (counter->collect_stat) { | 232 | if (counter->collect_stat) { |
231 | struct saved_value *v = saved_value_lookup(counter, cpu, true); | 233 | struct saved_value *v = saved_value_lookup(counter, cpu, true); |
232 | update_stats(&v->stats, count[0]); | 234 | update_stats(&v->stats, count); |
233 | } | 235 | } |
234 | } | 236 | } |
235 | 237 | ||
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 933de91831fa..ef00c91e2553 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c | |||
@@ -277,7 +277,7 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel | |||
277 | perf_evsel__compute_deltas(evsel, cpu, thread, count); | 277 | perf_evsel__compute_deltas(evsel, cpu, thread, count); |
278 | perf_counts_values__scale(count, config->scale, NULL); | 278 | perf_counts_values__scale(count, config->scale, NULL); |
279 | if (config->aggr_mode == AGGR_NONE) | 279 | if (config->aggr_mode == AGGR_NONE) |
280 | perf_stat__update_shadow_stats(evsel, count->values, cpu); | 280 | perf_stat__update_shadow_stats(evsel, count->val, cpu); |
281 | break; | 281 | break; |
282 | case AGGR_GLOBAL: | 282 | case AGGR_GLOBAL: |
283 | aggr->val += count->val; | 283 | aggr->val += count->val; |
@@ -320,7 +320,6 @@ int perf_stat_process_counter(struct perf_stat_config *config, | |||
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->stats; | 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; | ||
324 | int i, ret; | 323 | int i, ret; |
325 | 324 | ||
326 | aggr->val = aggr->ena = aggr->run = 0; | 325 | aggr->val = aggr->ena = aggr->run = 0; |
@@ -360,8 +359,7 @@ int perf_stat_process_counter(struct perf_stat_config *config, | |||
360 | /* | 359 | /* |
361 | * Save the full runtime - to allow normalization during printout: | 360 | * Save the full runtime - to allow normalization during printout: |
362 | */ | 361 | */ |
363 | val = counter->scale * *count; | 362 | perf_stat__update_shadow_stats(counter, *count, 0); |
364 | perf_stat__update_shadow_stats(counter, &val, 0); | ||
365 | 363 | ||
366 | return 0; | 364 | return 0; |
367 | } | 365 | } |
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 47915df346fb..490b78aa7230 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h | |||
@@ -82,7 +82,7 @@ typedef void (*new_line_t )(void *ctx); | |||
82 | 82 | ||
83 | void perf_stat__init_shadow_stats(void); | 83 | void perf_stat__init_shadow_stats(void); |
84 | void perf_stat__reset_shadow_stats(void); | 84 | void perf_stat__reset_shadow_stats(void); |
85 | void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, | 85 | void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count, |
86 | int cpu); | 86 | int cpu); |
87 | struct perf_stat_output_ctx { | 87 | struct perf_stat_output_ctx { |
88 | void *ctx; | 88 | void *ctx; |